Skip to content

[Question]: error when use KG search , error:" float() argument must be a string or a real number, not 'NoneType'" #6177

@anthonya0713

Description

@anthonya0713

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (Language Policy).
  • Non-english title submitions will be closed directly ( 非英文标题的提交将会被直接关闭 ) (Language Policy).
  • Please do not modify this template :) and fill in all the required fields.

Describe your problem

    def _relation_info_from_(self, es_res, sim_thr=0.3):
        res = {}
        es_res = self.dataStore.getFields(es_res, ["content_with_weight", "_score", "from_entity_kwd", "to_entity_kwd",
                                                   "weight_int"])
        for _, ent in es_res.items():
            if float(ent["_score"]) < sim_thr:
                continue
            f, t = sorted([ent["from_entity_kwd"], ent["to_entity_kwd"]])
            if isinstance(f, list):
                f = f[0]
            if isinstance(t, list):
                t = t[0]
            res[(f, t)] = {
                "sim": float(ent["_score"]),
                "pagerank": float(ent.get("weight_int", 0)),
                "description": ent["content_with_weight"]
            }
        return res

2025-03-17 10:29:51,139 ERROR 19 float() argument must be a string or a real number, not 'NoneType'
Traceback (most recent call last):
File "/ragflow/api/apps/chunk_app.py", line 314, in retrieval_test
ck = settings.kg_retrievaler.retrieval(question,
File "/ragflow/graphrag/search.py", line 167, in retrieval
rels_from_txt = self.get_relevant_relations_by_txt(qst, filters, idxnms, kb_ids, emb_mdl, rel_sim_threshold)
File "/ragflow/graphrag/search.py", line 125, in get_relevant_relations_by_txt
return self.relation_info_from(es_res, sim_thr)
File "/ragflow/graphrag/search.py", line 91, in relation_info_from
if float(ent["_score"]) < sim_thr:
TypeError: float() argument must be a string or a real number, not 'NoneType'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions