learningai commited on
Commit
a8c8525
·
1 Parent(s): efbada4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -20
app.py CHANGED
@@ -1,29 +1,16 @@
1
 
2
 
3
- from transformers import AutoTokenizer
4
- import transformers
5
  import torch
6
  from huggingface_hub import login
7
 
8
  login(token="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")
9
 
10
- model = "meta-llama/Llama-2-7b-chat-hf"
 
11
 
12
- tokenizer = AutoTokenizer.from_pretrained(model)
13
- pipeline = transformers.pipeline(
14
- "text-generation",
15
- model=model,
16
- torch_dtype=torch.float16,
17
- device_map="auto",
18
- )
19
 
20
- sequences = pipeline(
21
- 'I liked "Breaking Bad" and "Band of Brothers". Do you have any recommendations of other shows I might like?\n',
22
- do_sample=True,
23
- top_k=10,
24
- num_return_sequences=1,
25
- eos_token_id=tokenizer.eos_token_id,
26
- max_length=200,
27
- )
28
- for seq in sequences:
29
- print(f"Result: {seq['generated_text']}")
 
1
 
2
 
 
 
3
  import torch
4
  from huggingface_hub import login
5
 
6
  login(token="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")
7
 
8
+ # Use a pipeline as a high-level helper
9
+ from transformers import pipeline
10
 
11
+ pipe = pipeline("text-generation", model="meta-llama/Llama-2-7b-chat-hf")
 
 
 
 
 
 
12
 
13
+ print("Providing input to the pipeline.....")
14
+
15
+ response = pipe("Hello, how are you?")
16
+ print(response)