bmas10 commited on
Commit
be7cd6f
·
verified ·
1 Parent(s): 2c1f1d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -3,10 +3,23 @@
3
  #importing the required libraries including transformers
4
  import gradio as gr
5
  from huggingface_hub import InferenceClient
6
- from transformers import pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- from huggingface_hub import login
9
- login()
10
 
11
  """
12
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
 
3
  #importing the required libraries including transformers
4
  import gradio as gr
5
  from huggingface_hub import InferenceClient
6
+ from transformers import pipeline,AutoModelForCausalLM, AutoTokenizer
7
+ import torch
8
+
9
+
10
+ # Load model and tokenizer
11
+ model_name = "meta-llama/Llama-2-7b-chat-hf"
12
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
13
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
14
+
15
+ def chat(input_text, history=[]):
16
+ history.append(input_text)
17
+ prompt = "\n".join(history) + "\nAI:" # Simple conversational format
18
+ inputs = tokenizer(prompt, retur
19
+
20
+
21
+
22
 
 
 
23
 
24
  """
25
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference