丽水查重代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
2.0KB

  1. import os
  2. os.environ['KMP_DUPLICATE_LIB_OK']='True'
  3. # 方法1
  4. from modelscope.pipelines import pipeline
  5. from modelscope.utils.constant import Tasks
  6. # damo/nlp_corom_sentence-embedding_chinese-base-ecom
  7. # damo/nlp_corom_sentence-embedding_chinese-base
  8. # damo/nlp_corom_sentence-embedding_chinese-tiny
  9. model_id = "damo/nlp_corom_sentence-embedding_chinese-base-ecom"
  10. # model_id = "damo/nlp_gpt3_text-generation_chinese-base"
  11. pipeline_se = pipeline(Tasks.sentence_embedding, model=model_id, max_length=1024)
  12. #
  13. # 当输入包含“soure_sentence”与“sentences_to_compare”时,会输出source_sentence中首个句子与sentences_to_compare中每个句子的向量表示,以及source_sentence中首个句子与sentences_to_compare中每个句子的相似度。
  14. sentences_to_compare = [
  15. '''根据不同的季度、网红热点信息主动给用户推送热门景区和景点的游玩信息''',
  16. '''开发一个在线商品销售商城,提供旅游路线上的相关特产和旅游商品的查阅及下单功能''',
  17. '''推送相关旅游产品折扣信息以及景区景点举办的篝火晚会、烟花盛宴等活动内容,可通过线下报名参与。'''
  18. ]
  19. inputs = {
  20. "source_sentence": [
  21. # '''模块功能:提供商家信息查询和种植区域查询等功能。功能描述:商家信息包括名称、地址、法人、联系方式、经营范围、投资规模等,种植区域主要是指丽水香茶种植区域的面积、位置、高程等信息,政府工作人员可根据多个查询条件完成上述信息的查询。'''
  22. '''展示乡村游中相关乡村举办的庆典活动,包含庆典举办时间、内容等'''
  23. ],
  24. "sentences_to_compare": sentences_to_compare
  25. }
  26. result = pipeline_se(input=inputs)
  27. print(result["scores"])
  28. arr = result["scores"]
  29. max_value = max(arr)
  30. max_index = arr.index(max_value)
  31. print("最大值:", max_value)
  32. print("最相识内容:", sentences_to_compare[max_index])
  33. # #
  34. #