fix(neuron): avoid using Levenshtein

This commit is contained in:
David Corvoysier 2025-02-19 14:05:29 +00:00
parent 88a0948692
commit 6f92198eb9

View File

@ -1,4 +1,3 @@
import Levenshtein
import pytest
@ -82,15 +81,13 @@ async def test_model_multiple_requests(tgi_service, neuron_generate_load):
assert len(responses) == 4
expectations = {
"gpt2": "\n\nDeep learning is a new field of research that has been around for a while",
"llama": " A Beginners Guide\nDeep learning is a subset of machine learning that involves the use",
"mistral": "\nWhat is Deep Learning?\nDeep Learning is a type of machine learning that",
"qwen2": " - Part 1\n\nDeep Learning is a subset of Machine Learning that is based on",
"granite": "\n\nDeep Learning is a subset of Machine Learning, which is a branch of Art",
"gpt2": "Deep learning is a new field of research that has been around for a while",
"llama": "Deep learning is a subset of machine learning that involves the use",
"mistral": "Deep Learning is a type of machine learning that",
"qwen2": "Deep Learning is a subset of Machine Learning that is based on",
"granite": "Deep Learning is a subset of Machine Learning, which is a branch of Art",
}
expected = expectations[tgi_service.client.service_name]
for r in responses:
assert r.details.generated_tokens == 17
# Compute the similarity with the expectation using the levenshtein distance
# We should not have more than two substitutions or additions
assert Levenshtein.distance(r.generated_text, expected) < 3
assert expected in r.generated_text