Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS]: Does the onnx model support Chinese when used to determine similarity? #634

Open
qiangruoyu opened this issue Jul 22, 2024 · 2 comments

Comments

@qiangruoyu
Copy link

Documentation Link

No response

Describe the problem

Does the onnx model support Chinese when used to determine similarity?

Describe the improvement

There is no detailed documentation about this model. Could you please provide a detailed explanation of how this model was trained.

Anything else?

No response

@SimFG
Copy link
Collaborator

SimFG commented Jul 23, 2024

the onnx model only support English, and it is a very small model, only suitable for demo.

@xiaolele1314
Copy link

use sbert,and custom similarity_evaluation
example:
class JxyEvaluation(SimilarityEvaluation):
model_instance = None

def __init__(self):
    if JxyEvaluation.model_instance is None:
        # 使用 with torch.no_grad() 来降低内存使用(zhi'zuo2推理)
        with torch.no_grad():
            JxyEvaluation.model_instance = BertSimilarity()
    self.model = JxyEvaluation.model_instance

def evaluation(
    self, src_dict: Dict[str, Any], cache_dict: Dict[str, Any], **_
) -> float:
    try:
        src_question = src_dict["question"]
        cache_question = cache_dict["question"]
        if src_question.lower() == cache_question.lower():
            return 2
        start_time = time.time()
        score = float(self.model.similarity(src_question, cache_question))
        print("Cache Time consuming: {:.2f}s".format(
            time.time() - start_time))
        return score+1
    except Exception as e:  # pylint: disable=W0703
        return 0

def range(self) -> Tuple[float, float]:
    return 0.0, 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants