Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import AutoModelForSeq2SeqLM, T5Tokenizer
|
| 3 |
+
|
| 4 |
+
def generate_response(input_prompt):
|
| 5 |
+
fine_tuned_model_path = "Robin246/inxai" # Update with your Hugging Face model path
|
| 6 |
+
|
| 7 |
+
# Load the fine-tuned model and tokenizer
|
| 8 |
+
fine_tuned_model = AutoModelForSeq2SeqLM.from_pretrained(fine_tuned_model_path)
|
| 9 |
+
tokenizer = T5Tokenizer.from_pretrained(fine_tuned_model_path)
|
| 10 |
+
|
| 11 |
+
input_text = f"Input prompt: {input_prompt}"
|
| 12 |
+
|
| 13 |
+
input_ids = tokenizer.encode(input_text, return_tensors="pt", max_length=64, padding="max_length", truncation=True)
|
| 14 |
+
output_ids = fine_tuned_model.generate(input_ids, max_length=256, num_return_sequences=1, num_beams=1, early_stopping=True)
|
| 15 |
+
generated_output = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
| 16 |
+
|
| 17 |
+
return generated_output
|
| 18 |
+
|
| 19 |
+
def main():
|
| 20 |
+
st.title('INXAI LLM model')
|
| 21 |
+
user_input = st.text_input('Input Prompt:', '')
|
| 22 |
+
|
| 23 |
+
if st.button('Generate'):
|
| 24 |
+
response = generate_response(user_input)
|
| 25 |
+
st.write('Generated Reply:', response)
|
| 26 |
+
|
| 27 |
+
if __name__ == '__main__':
|
| 28 |
+
main()
|