phucdt89s commited on
Commit
d20c50f
verified
1 Parent(s): eda8f6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -1,18 +1,14 @@
1
- import torch
2
- from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import gradio as gr
4
 
5
- # Load model and tokenizer
6
- MODEL_NAME = "vilm/vinallama-2.7b-chat-GGUF"
7
- tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
8
- model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
9
 
10
  # Define chatbot function
11
  def chatbot(input_text):
12
- inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
13
- outputs = model.generate(inputs["input_ids"], max_length=200, do_sample=True, temperature=0.7)
14
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
15
- return response
16
 
17
  # Create Gradio interface
18
  interface = gr.Interface(fn=chatbot, inputs="text", outputs="text", title="Vinamallama 7B Chatbot")
 
1
+ from llama_cpp import Llama
 
2
  import gradio as gr
3
 
4
+ # Load model
5
+ MODEL_PATH = "./model/vinallama-2.7b-chat.gguf" # 膼瓢峄漬g d岷玭 膽岷縩 m么 h矛nh GGUF
6
+ model = Llama(model_path=MODEL_PATH)
 
7
 
8
  # Define chatbot function
9
  def chatbot(input_text):
10
+ response = model(input_text, max_tokens=200, temperature=0.7)
11
+ return response['choices'][0]['text']
 
 
12
 
13
  # Create Gradio interface
14
  interface = gr.Interface(fn=chatbot, inputs="text", outputs="text", title="Vinamallama 7B Chatbot")