Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load Mixtral model
|
6 |
+
model_name = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
|
9 |
+
|
10 |
+
def solve_problem(prompt):
|
11 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
12 |
+
output = model.generate(**inputs, max_length=500)
|
13 |
+
return tokenizer.decode(output[0])
|
14 |
+
|
15 |
+
# Create Gradio UI
|
16 |
+
iface = gr.Interface(fn=solve_problem,
|
17 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter a JEE/NEET question..."),
|
18 |
+
outputs="text",
|
19 |
+
title="Prof. Cool - JEE/NEET Solver",
|
20 |
+
description="Ask a complex JEE Advanced or NEET question and get a detailed solution.")
|
21 |
+
|
22 |
+
iface.launch()
|