Download app.py from Jchery3/Test: direct link, hf CLI and curl.
- Browser
- Download file 786 Bytes
-
https://huggingface.co/spaces/Jchery3/Test/resolve/main/app.py
- Command line
-
hf download hf://spaces/Jchery3/Test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Jchery3/Test/resolve/main/app.py
786 Bytes
| 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() |