Skip to content

Commit

Permalink
Concept linking outcommented
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasGLund99 committed Jan 19, 2024
1 parent 9a6ccac commit 987caba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
19 changes: 16 additions & 3 deletions relation_extraction/multilingual/llm_messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@
import requests
import re
import os
from llama_cpp import Llama

class LLMMessenger(APIHandler):

def API_endpoint():
return "http://knox-proxy01.srv.aau.dk/llama-api/llama"

def send_request(request):
HEADERS = {"Access-Authorization": os.getenv("ACCESS_SECRET")}
response = requests.post(url=LLMMessenger.API_endpoint(), json=request, headers=HEADERS)
return response
# Put the location of the GGUF model that you've download from HuggingFace here
model_path = "relation_extraction\multilingual\llama-2-7b-chat.Q2_K.gguf"

# Create a llama model
model = Llama(model_path=model_path, n_ctx=4096)

prompt = f"""<s>[INST] <<SYS>>
{request["system_message"]}
<</SYS>>
{request["user_message"]} [/INST]"""

# Run the model
output = model(prompt, max_tokens=request["max_tokens"], echo=True)

return output

def process_message(response):
print("Recieved response from Llama2...")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#For python
#----------
# Concept linking
-r concept_linking/requirements.txt
# -r concept_linking/requirements.txt

# Relation extraction
-r relation_extraction/requirements.txt
2 changes: 1 addition & 1 deletion requirements_docker.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#For docker
#----------
# Concept linking
-r /code/concept_linking/requirements.txt
# -r /code/concept_linking/requirements.txt

# Relation extraction
-r /code/relation_extraction/requirements.txt
4 changes: 2 additions & 2 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import os
from relation_extraction.relation_extractor import RelationExtractor
from concept_linking.main import entity_type_classification
# from concept_linking.main import entity_type_classification

app = Flask(__name__)

Expand All @@ -22,7 +22,7 @@ def do_triple_construction():
post_json = json.loads(post_data)

RelationExtractor.begin_extraction(post_json) # Relation Extraction
entity_type_classification(post_json) # Concept Linking
# entity_type_classification(post_json) # Concept Linking

message = "Post request was successfully processed. Relation Extraction and Concept Linking completed."
return jsonify(message=message), 200
Expand Down

0 comments on commit 987caba

Please sign in to comment.