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