lab2 test
Browse files- app.py +11 -8
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
llm = Llama.from_pretrained(
|
6 |
-
repo_id="ID2223JR/gguf_model",
|
7 |
-
filename="GGUF_FILE",
|
8 |
-
)
|
9 |
|
|
|
|
|
10 |
|
11 |
# Data storage
|
12 |
ingredients_list = []
|
@@ -40,8 +38,13 @@ def submit_to_model():
|
|
40 |
ingredients_list
|
41 |
)
|
42 |
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
# App
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Load model directly
|
4 |
+
from transformers import AutoModel, AutoTokenizer
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
model = AutoModel.from_pretrained("ID2223JR/gguf_model")
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("ID2223JR/gguf_model")
|
8 |
|
9 |
# Data storage
|
10 |
ingredients_list = []
|
|
|
38 |
ingredients_list
|
39 |
)
|
40 |
|
41 |
+
# Tokenize and pass the prompt to the model
|
42 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
43 |
+
outputs = model.generate(**inputs, max_new_tokens=100)
|
44 |
+
|
45 |
+
# Decode the model output
|
46 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
47 |
+
return response
|
48 |
|
49 |
|
50 |
# App
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
gradio==5.1.0
|
2 |
-
llama-cpp-python==0.2.24
|
|
|
|
1 |
gradio==5.1.0
|
2 |
+
llama-cpp-python==0.2.24
|
3 |
+
transformers==4.46.3
|