shangab commited on
Commit
2158585
1 Parent(s): bbe376b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +10 -11
  2. requirements.txt +3 -1
app.py CHANGED
@@ -1,15 +1,16 @@
1
  import requests as rq
2
  import streamlit as st
3
- import os
 
4
 
5
- API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B"
6
- HF_LLAMA3_TOKEN = os.getenv("HF_LLAMA3_TOKEN")
7
- headers = {"Authorization": "Bearer " + HF_LLAMA3_TOKEN}
 
8
 
9
 
10
- def query(payload):
11
- response = rq.post(API_URL, headers=headers, json=payload)
12
- return response.json()
13
 
14
 
15
  st.title("LLama3 8B T")
@@ -17,7 +18,5 @@ st.subheader("This is a demo of the LLama3 8B T model.")
17
 
18
  user_input = st.text_area("Enter your text here:")
19
  if st.button("Submit"):
20
- output = query({
21
- "inputs": user_input,
22
- })
23
- st.write(output)
 
1
  import requests as rq
2
  import streamlit as st
3
+ import transformers
4
+ import torch
5
 
6
+ model_id = "meta-llama/Meta-Llama-3-8B"
7
+ pipeline = transformers.pipeline(
8
+ "text-generation", model=model_id, model_kwargs={"torch_dtype": torch.bfloat16}, device_map="auto"
9
+ )
10
 
11
 
12
+ def query(question):
13
+ return pipeline(question)
 
14
 
15
 
16
  st.title("LLama3 8B T")
 
18
 
19
  user_input = st.text_area("Enter your text here:")
20
  if st.button("Submit"):
21
+ answer = query(user_input)
22
+ st.write(answer)
 
 
requirements.txt CHANGED
@@ -1,2 +1,4 @@
1
  requests
2
- streamlit
 
 
 
1
  requests
2
+ streamlit
3
+ transformers
4
+ torch