Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
from flask import Flask, request, jsonify
|
2 |
-
from langchain_community.llms import LlamaCpp
|
3 |
-
import os
|
4 |
-
app = Flask(__name__)
|
5 |
-
|
6 |
-
n_gpu_layers = 0
|
7 |
-
n_batch = 1024
|
8 |
-
|
9 |
-
|
10 |
-
llm = LlamaCpp(
|
11 |
-
model_path="Phi-3-mini-4k-instruct-q4.gguf", # path to GGUF file
|
12 |
-
temperature=0.1,
|
13 |
-
n_gpu_layers=n_gpu_layers,
|
14 |
-
n_batch=n_batch,
|
15 |
-
verbose=True,
|
16 |
-
n_ctx=4096
|
17 |
-
)
|
18 |
-
file_size = os.stat('Phi-3-mini-4k-instruct-q4.gguf')
|
19 |
-
print("model size ====> :", file_size.st_size, "bytes")
|
20 |
-
|
21 |
-
|
22 |
-
@app.route('/', methods=['POST'])
|
23 |
-
def get_skills():
|
24 |
-
cv_body = request.json.get('cv_body')
|
25 |
-
|
26 |
-
# Simple inference example
|
27 |
-
output = llm(
|
28 |
-
f"<|user|>\n{cv_body}<|end|>\n<|assistant|>Can you list the skills mentioned in the CV?<|end|>",
|
29 |
-
max_tokens=256, # Generate up to 256 tokens
|
30 |
-
stop=["<|end|>"],
|
31 |
-
echo=True, # Whether to echo the prompt
|
32 |
-
)
|
33 |
-
|
34 |
-
return jsonify({'skills': output})
|
35 |
-
|
36 |
-
if __name__ == '__main__':
|
37 |
app.run()
|
|
|
1 |
+
from flask import Flask, request, jsonify
|
2 |
+
from langchain_community.llms import LlamaCpp
|
3 |
+
import os
|
4 |
+
app = Flask(__name__)
|
5 |
+
|
6 |
+
n_gpu_layers = 0
|
7 |
+
n_batch = 1024
|
8 |
+
|
9 |
+
|
10 |
+
llm = LlamaCpp(
|
11 |
+
model_path="Phi-3-mini-4k-instruct-q4.gguf", # path to GGUF file
|
12 |
+
temperature=0.1,
|
13 |
+
n_gpu_layers=n_gpu_layers,
|
14 |
+
n_batch=n_batch,
|
15 |
+
verbose=True,
|
16 |
+
n_ctx=4096
|
17 |
+
)
|
18 |
+
file_size = os.stat('Phi-3-mini-4k-instruct-q4.gguf')
|
19 |
+
print("model size ====> :", file_size.st_size, "bytes")
|
20 |
+
|
21 |
+
|
22 |
+
@app.route('/', methods=['POST'])
|
23 |
+
def get_skills():
|
24 |
+
cv_body = request.json.get('cv_body')
|
25 |
+
|
26 |
+
# Simple inference example
|
27 |
+
output = llm(
|
28 |
+
f"<|user|>\n{cv_body}<|end|>\n<|assistant|>Can you list the skills mentioned in the CV?<|end|>",
|
29 |
+
max_tokens=256, # Generate up to 256 tokens
|
30 |
+
stop=["<|end|>"],
|
31 |
+
echo=True, # Whether to echo the prompt
|
32 |
+
)
|
33 |
+
|
34 |
+
return jsonify({'skills': output})
|
35 |
+
|
36 |
+
if __name__ == '__main__':
|
37 |
app.run()
|