Downloads · 30 days
0
Salms/ai_salms
ai_salms is a machine learning model from Salms. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
0
Access
Public
Updated Dec 6, 2022
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other1.5 KB · 61%
From the Hugging Face model README
import spacy import random
nlp = spacy.load('en_core_web_md')
responses = [ "I'm sorry, I don't understand what you're trying to say.", "Could you please provide more information?", "I'm sorry, I'm not able to help with that.", "Can you please rephrase that?" ]
while True: # Get user input user_input = input("User: ")
# Parse user input using the Spacy model
doc = nlp(user_input)
# Identify the most similar pre-defined response
best_response = responses[0]
best_similarity = doc.similarity(nlp(responses[0]))
for response in responses:
similarity = doc.similarity(nlp(response))
if similarity > best_similarity:
best_response = response
best_similarity = similarity
# Respond with the most similar pre-defined response
print("Bot: " + best_response)