Spaces:
Runtime error
Runtime error
Commit
Β·
b6f4d2d
1
Parent(s):
77217c7
update
Browse files- app.py +25 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load model and tokenizer
|
6 |
+
model_id = "prasenjeethowlader099/zetallm_4"
|
7 |
+
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
9 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda" if torch.cuda.is_available() else "cpu")
|
10 |
+
|
11 |
+
# Chat function
|
12 |
+
def chat(prompt, history=[]):
|
13 |
+
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
|
14 |
+
output = model.generate(input_ids, max_new_tokens=200, do_sample=True, top_k=50, top_p=0.95, temperature=0.7)
|
15 |
+
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
16 |
+
return response
|
17 |
+
|
18 |
+
# Gradio UI
|
19 |
+
gr.Interface(
|
20 |
+
fn=chat,
|
21 |
+
inputs=gr.Textbox(lines=5, label="Ask Zeeta"),
|
22 |
+
outputs=gr.Textbox(label="Zeeta's Response"),
|
23 |
+
title="CodeAgent Zeeta LLM",
|
24 |
+
description="Chat with prasenjeethowlader099/zetallm_4"
|
25 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
gradio
|