Update app.py
Browse files
app.py
CHANGED
@@ -7,20 +7,20 @@ import json
|
|
7 |
import pyarrow.parquet as pq
|
8 |
|
9 |
# Hugging Face ν ν° νμΈ
|
10 |
-
|
11 |
|
12 |
-
if not
|
13 |
-
raise ValueError("
|
14 |
|
15 |
# λͺ¨λΈ μ 보 νμΈ
|
16 |
-
api = HfApi(token=
|
17 |
|
18 |
try:
|
19 |
-
client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct", token=
|
20 |
except Exception as e:
|
21 |
print(f"rror initializing InferenceClient: {e}")
|
22 |
# λ체 λͺ¨λΈμ μ¬μ©νκ±°λ μ€λ₯ μ²λ¦¬λ₯Ό μννμΈμ.
|
23 |
-
# μ: client = InferenceClient("gpt2", token=
|
24 |
|
25 |
# νμ¬ μ€ν¬λ¦½νΈμ λλ ν 리λ₯Ό κΈ°μ€μΌλ‘ μλ κ²½λ‘ μ€μ
|
26 |
currentdir = os.path.dirname(os.path.abspath(file))
|
@@ -34,7 +34,7 @@ try:
|
|
34 |
print(f"컬λΌ: {df.columns}")
|
35 |
except Exception as e:
|
36 |
print(f"Parquet νμΌ λ‘λ μ€ μ€λ₯ λ°μ: {e}")
|
37 |
-
df = pd.atarame(columns=['instruction', 'responsea']) # λΉ
|
38 |
|
39 |
def getanswer(question):
|
40 |
matchinganswer = df[df['instruction'] == question]['responsea'].values
|
@@ -69,7 +69,7 @@ def respond(
|
|
69 |
fullprompt += f"Human: {message}\nAI:"
|
70 |
|
71 |
APIL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-70B-Instruct"
|
72 |
-
headers = {"Authorization": f"Bearer {
|
73 |
|
74 |
def query(payload):
|
75 |
response = requests.post(APIL, headers=headers, json=payload)
|
@@ -114,13 +114,13 @@ demo = gr.ChatInterface(
|
|
114 |
Parquet νμΌμ μλ λ΄μ©μ λν΄μλ μ μ ν λλ΅μ μμ±ν΄ μ£ΌμΈμ.
|
115 |
""", label="μμ€ν
ν둬ννΈ"),
|
116 |
gr.Slider(minimum=1, maximum=4000, value=1000, step=1, label="Max new tokens"),
|
117 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="
|
118 |
gr.Slider(
|
119 |
minimum=0.1,
|
120 |
maximum=1.0,
|
121 |
value=0.95,
|
122 |
step=0.05,
|
123 |
-
label="
|
124 |
),
|
125 |
],
|
126 |
examples=[
|
|
|
7 |
import pyarrow.parquet as pq
|
8 |
|
9 |
# Hugging Face ν ν° νμΈ
|
10 |
+
hftoken = "μλ‘μ΄ ν ν°"
|
11 |
|
12 |
+
if not hftoken:
|
13 |
+
raise ValueError("H νκ²½ λ³μκ° μ€μ λμ§ μμμ΅λλ€.")
|
14 |
|
15 |
# λͺ¨λΈ μ 보 νμΈ
|
16 |
+
api = HfApi(token=hftoken)
|
17 |
|
18 |
try:
|
19 |
+
client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct", token=hftoken)
|
20 |
except Exception as e:
|
21 |
print(f"rror initializing InferenceClient: {e}")
|
22 |
# λ체 λͺ¨λΈμ μ¬μ©νκ±°λ μ€λ₯ μ²λ¦¬λ₯Ό μννμΈμ.
|
23 |
+
# μ: client = InferenceClient("gpt2", token=hftoken)
|
24 |
|
25 |
# νμ¬ μ€ν¬λ¦½νΈμ λλ ν 리λ₯Ό κΈ°μ€μΌλ‘ μλ κ²½λ‘ μ€μ
|
26 |
currentdir = os.path.dirname(os.path.abspath(file))
|
|
|
34 |
print(f"컬λΌ: {df.columns}")
|
35 |
except Exception as e:
|
36 |
print(f"Parquet νμΌ λ‘λ μ€ μ€λ₯ λ°μ: {e}")
|
37 |
+
df = pd.atarame(columns=['instruction', 'responsea']) # λΉ atarame μμ±
|
38 |
|
39 |
def getanswer(question):
|
40 |
matchinganswer = df[df['instruction'] == question]['responsea'].values
|
|
|
69 |
fullprompt += f"Human: {message}\nAI:"
|
70 |
|
71 |
APIL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-70B-Instruct"
|
72 |
+
headers = {"Authorization": f"Bearer {hftoken}"}
|
73 |
|
74 |
def query(payload):
|
75 |
response = requests.post(APIL, headers=headers, json=payload)
|
|
|
114 |
Parquet νμΌμ μλ λ΄μ©μ λν΄μλ μ μ ν λλ΅μ μμ±ν΄ μ£ΌμΈμ.
|
115 |
""", label="μμ€ν
ν둬ννΈ"),
|
116 |
gr.Slider(minimum=1, maximum=4000, value=1000, step=1, label="Max new tokens"),
|
117 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="temperature"),
|
118 |
gr.Slider(
|
119 |
minimum=0.1,
|
120 |
maximum=1.0,
|
121 |
value=0.95,
|
122 |
step=0.05,
|
123 |
+
label="top-p (nucleus sampling)",
|
124 |
),
|
125 |
],
|
126 |
examples=[
|