Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import torch | |
| # Load the tokenizer | |
| model_name = "TuringsSolutions/TechLegalV1" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| # Load the model | |
| # Assuming it's a CausalLM model, you might need to adjust based on your model's architecture | |
| model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True) | |
| # Function to make predictions | |
| def predict(text): | |
| inputs = tokenizer(text, return_tensors="pt") | |
| with torch.no_grad(): | |
| outputs = model.generate(**inputs) | |
| return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| # Create a Gradio interface | |
| iface = gr.Interface( | |
| fn=predict, | |
| inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."), | |
| outputs="text", | |
| title="Tech Legal Model", | |
| description="A model for analyzing tech legal documents." | |
| ) | |
| # Launch the interface | |
| if __name__ == "__main__": | |
| iface.launch() | |