Spaces:
Configuration error
Configuration error
#endpointe ait model | |
import requests | |
from config import HUGGINGFACE_API_URL, HUGGINGFACE_API_KEY | |
def get_huggingface_prediction(input_data): #input_data'yı main.py ile entegre etmeliyim | |
headers = { | |
"Authorization": f"Bearer {HUGGINGFACE_API_KEY}" | |
} | |
payload = { | |
"inputs": input_data | |
} | |
response = requests.post(HUGGINGFACE_API_URL, headers=headers, json=payload) | |
return response.json() | |
def calculate_similarity(text1, text2): | |
model = SentenceTransformer('paraphrase-MiniLM-L6-v2') | |
embedding1 = model.encode(text1, convert_to_tensor=True) | |
embedding2 = model.encode(text2, convert_to_tensor=True) | |
similarity_score = util.pytorch_cos_sim(embedding1, embedding2) | |
return similarity_score.item() |