-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
如何直接上传QA对信息,不需要大模型来帮我生成 #4664
Comments
要直接上传QA对信息而不需要大模型来生成,可以使用Dify的知识API通过文本创建文档。以下是一个示例: curl --location --request POST 'https://api.dify.ai/v1/datasets/<uuid:dataset_id>/document/create_by_text' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "QA Pairs",
"text": "Q: What is Dify?\nA: Dify means Do it for you.\nQ: How to use Dify?\nA: You can use Dify by accessing its API.",
"indexing_technique": "high_quality",
"process_rule": {
"rules": {
"pre_processing_rules": [{
"id": "remove_extra_spaces",
"enabled": true
}, {
"id": "remove_urls_emails",
"enabled": true
}],
"segmentation": {
"separator": "###",
"max_tokens": 500
}
},
"mode": "custom"
}
}' 这个命令将直接从提供的文本中创建包含QA对的文档。 如果你有包含QA对的CSV文件,可以使用 from werkzeug.datastructures import FileStorage
from core.rag.index_processor.processor.qa_index_processor import QAIndexProcessor
# 假设 'file' 是包含你的CSV文件的FileStorage对象
file = FileStorage(stream=open('qa_pairs.csv', 'rb'), filename='qa_pairs.csv')
qa_processor = QAIndexProcessor()
documents = qa_processor.format_by_template(file=file)
# 现在你可以将这些文档加载到你的数据集中
dataset = Dataset(id='<uuid:dataset_id>', indexing_technique='high_quality')
qa_processor.load(dataset=dataset, documents=documents) 这种方法允许你直接从CSV文件上传QA对,而不需要使用大模型来生成它们[1][2][3].
|
The support of this function is needed. Currently, in many businesses, there is already a content library of QA pairs. There is no need for a large model to generate QA pairs. They can be directly uploaded to the knowledge base. Through Q, problems can be matched, and then the corresponding A can be handed over to the LLM as the query content of the knowledge base for processing. |
1 use create_by_text api to create empty qa docment
2 use segments api to upload qa pair
|
Self Checks
Provide a description of requested docs changes
目前没有找到能直接导入QA对的地方。只有上传一个文件后,选择QA分段模式,但是此时我并不想通过大模型生成很多QA对。
The text was updated successfully, but these errors were encountered: