Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
+
|
| 4 |
+
# Load the model and tokenizer
|
| 5 |
+
model_name = "jondurbin/airoboros-gpt-3.5-turbo-100k-7b"
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
+
|
| 9 |
+
def evaluate_document(doc_text, question):
|
| 10 |
+
prompt = f"Document: {doc_text}\nCriteria Question: {question}\nRate on a scale of 0 to 1:"
|
| 11 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 12 |
+
outputs = model.generate(inputs['input_ids'], max_length=150)
|
| 13 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 14 |
+
return result
|
| 15 |
+
|
| 16 |
+
# Set up the Gradio interface
|
| 17 |
+
interface = gr.Interface(fn=evaluate_document, inputs=["text", "text"], outputs="text")
|
| 18 |
+
|
| 19 |
+
# Launch the interface
|
| 20 |
+
interface.launch()
|