chore: remove st
Browse files
app.py
CHANGED
|
@@ -2,8 +2,6 @@
|
|
| 2 |
import os
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
|
| 5 |
-
st.set_page_config(page_title="Chat", page_icon=":page_facing_up:")
|
| 6 |
-
|
| 7 |
load_dotenv()
|
| 8 |
|
| 9 |
from huggingface_hub import login
|
|
@@ -13,58 +11,14 @@ login(token=os.getenv("HUGGINGFACEHUB_API_KEY"))
|
|
| 13 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 14 |
import gradio as gr
|
| 15 |
|
|
|
|
| 16 |
# model_name="deepseek-ai/DeepSeek-R1-Distill-Qwen-7B" # 15G
|
| 17 |
model_name="meta-llama/Llama-3.2-3B-Instruct" # 6.5G
|
| 18 |
|
| 19 |
-
# #
|
| 20 |
-
# # HuggingFaceTB/SmolLM2-135M-Instruct
|
| 21 |
-
# # deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B
|
| 22 |
-
# checkpoint = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
| 23 |
-
# checkpoint = "meta-llama/Llama-3.2-3B-Instruct" # 6.5G
|
| 24 |
device = "mps" # "cuda" or "cpu"
|
| 25 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 26 |
model = AutoModelForCausalLM.from_pretrained(model_name).to(device)
|
| 27 |
|
| 28 |
-
# def predict(message, history):
|
| 29 |
-
# history.append({"role": "user", "content": message})
|
| 30 |
-
# input_text = tokenizer.apply_chat_template(history, tokenize=False)
|
| 31 |
-
# inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
|
| 32 |
-
# outputs = model.generate(inputs, max_new_tokens=100, temperature=0.2, top_p=0.9, do_sample=True)
|
| 33 |
-
# decoded = tokenizer.decode(outputs[0])
|
| 34 |
-
# response = decoded.split("<|im_start|>assistant\n")[-1].split("<|im_end|>")[0]
|
| 35 |
-
# return response
|
| 36 |
-
|
| 37 |
-
# demo = gr.ChatInterface(predict, type="messages")
|
| 38 |
-
|
| 39 |
-
# demo.launch()
|
| 40 |
-
|
| 41 |
-
# import os
|
| 42 |
-
# from dotenv import load_dotenv
|
| 43 |
-
|
| 44 |
-
# load_dotenv()
|
| 45 |
-
|
| 46 |
-
# from huggingface_hub import login
|
| 47 |
-
# login(token=os.getenv("HUGGINGFACEHUB_API_KEY"))
|
| 48 |
-
|
| 49 |
-
# pipe = pipeline(model=model_name, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
|
| 50 |
-
# prompt = """Let's go through this step-by-step:
|
| 51 |
-
# 1. You start with 15 muffins.
|
| 52 |
-
# 2. You eat 2 muffins, leaving you with 13 muffins.
|
| 53 |
-
# 3. You give 5 muffins to your neighbor, leaving you with 8 muffins.
|
| 54 |
-
# 4. Your partner buys 6 more muffins, bringing the total number of muffins to 14.
|
| 55 |
-
# 5. Your partner eats 2 muffins, leaving you with 12 muffins.
|
| 56 |
-
# If you eat 6 muffins, how many are left?"""
|
| 57 |
-
|
| 58 |
-
# torch.device("mps")
|
| 59 |
-
|
| 60 |
-
# pipeline = pipeline.to("mps")
|
| 61 |
-
|
| 62 |
-
# outputs = pipe(prompt, max_new_tokens=20, do_sample=True, top_k=10)
|
| 63 |
-
# print(f"processing")
|
| 64 |
-
|
| 65 |
-
# for output in outputs:
|
| 66 |
-
# print(f"Result: {output['generated_text']}")
|
| 67 |
-
|
| 68 |
system_prompt = (
|
| 69 |
"You are a customer officer that helps extract transaction id from the USER INPUT and determine the transaction type based on the transaction id. "
|
| 70 |
"To find transaction id, follow all the steps below: "
|
|
|
|
| 2 |
import os
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
|
|
|
|
|
|
|
| 5 |
load_dotenv()
|
| 6 |
|
| 7 |
from huggingface_hub import login
|
|
|
|
| 11 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 12 |
import gradio as gr
|
| 13 |
|
| 14 |
+
# # HuggingFaceTB/SmolLM2-135M-Instruct
|
| 15 |
# model_name="deepseek-ai/DeepSeek-R1-Distill-Qwen-7B" # 15G
|
| 16 |
model_name="meta-llama/Llama-3.2-3B-Instruct" # 6.5G
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
device = "mps" # "cuda" or "cpu"
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 20 |
model = AutoModelForCausalLM.from_pretrained(model_name).to(device)
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
system_prompt = (
|
| 23 |
"You are a customer officer that helps extract transaction id from the USER INPUT and determine the transaction type based on the transaction id. "
|
| 24 |
"To find transaction id, follow all the steps below: "
|