Spaces:
Sleeping
Sleeping
Download app.py from CeeJay00100/Ed_Bot: direct link, hf CLI and curl.
- Browser
- Download file 697 Bytes
-
https://huggingface.co/spaces/CeeJay00100/Ed_Bot/resolve/main/app.py
- Command line
-
hf download hf://spaces/CeeJay00100/Ed_Bot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/CeeJay00100/Ed_Bot/resolve/main/app.py
697 Bytes
| from transformers import TFT5ForConditionalGeneration, T5Tokenizer | |
| import gradio as gr | |
| model_name = "CeeJay00100/t5-edu-bot" | |
| tokenizer = T5Tokenizer.from_pretrained(model_name) | |
| model = TFT5ForConditionalGeneration.from_pretrained(model_name, from_pt=False) | |
| def ask_bot(question): | |
| input_text = "question: " + question | |
| inputs = tokenizer(input_text, return_tensors="tf", padding=True) | |
| outputs = model.generate(**inputs, max_length=100) | |
| return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| gr.Interface( | |
| fn=ask_bot, | |
| inputs="text", | |
| outputs="text", | |
| title="EdBot: Educational Chatbot", | |
| description="Ask any math or general knowledge question!" | |
| ).launch() |