mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-02 18:07:43 +00:00
6b626eb56d
* Commit init framework * Co-authored-by: Yuante Li (FESCO Adecco Human Resources) <v-yuanteli@microsoft.com> Co-authored-by: XianBW <XianBW@users.noreply.github.com> * add an import * refine the whole framework * benchmark related framework * fix black and isort errors * move requirements to folder * fix black again --------- Co-authored-by: Young <afe.young@gmail.com> Co-authored-by: xuyang1 <xuyang1@microsoft.com>
26 lines
718 B
Python
26 lines
718 B
Python
import unittest
|
|
|
|
from rdagent.oai.llm_utils import (
|
|
APIBackend,
|
|
calculate_embedding_distance_between_str_list,
|
|
)
|
|
|
|
|
|
class TestEmbedding(unittest.TestCase):
|
|
def test_embedding(self) -> None:
|
|
emb = APIBackend().create_embedding("hello")
|
|
assert emb is not None
|
|
assert isinstance(emb, list)
|
|
assert len(emb) > 0
|
|
|
|
def test_embedding_similarity(self) -> None:
|
|
similarity = calculate_embedding_distance_between_str_list(["Hello"], ["Hi"])[0][0]
|
|
assert similarity is not None
|
|
assert isinstance(similarity, float)
|
|
min_similarity_threshold = 0.8
|
|
assert similarity >= min_similarity_threshold
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|