意图识别
意图识别
意图识别的原理和需要准备的数据
引言
意图识别(Intent Recognition)是自然语言处理(NLP)中的一个重要任务。它的目标是理解用户的输入并确定其背后的意图。这在聊天机器人、虚拟助理和各种人机交互系统中尤为重要。为了实现意图识别,通常需要准备一系列有标签的数据。本篇文章将解释为什么需要准备这些数据,以及如何在程序中处理这些数据。
流程简介
相似度计算:将用户输入的句子与手动编写的例句进行相似度计算,以判定用户的意图。
提示词使用:在判断用户意图之后,需要使用对应意图的提示词,以达到更好的推理效果。
提示词设计:对于每个意图,涉及的提示词有两个:问题重写提示词和推理提示词。
问题重写提示词的主要功能有两个:
- 规范输入:用户的问题可能包含错别字或不完整的句子,通过问题重写,GPT 可以将输入规范化。
- 总结输入:将用户的输入和之前的历史对话放到问题重写提示词中,告诉大模型总结一个推理输入句子。
推理提示词:
- 专用推理提示词:一个大而全的推理提示词可能在某些问题上表现不佳。如果识别到用户的意图是课程查询类,只需要在推理提示词中添加与课程查询类相关的语句提示,大模型会专注于这个领域进行推理。
- 提示词优化:这部分较难,需要花费时间研究,并经过大量测试,才能得出较好的提示词。
总而言之,意图识别的关键在于分类和使用专用的提示词,以便大模型能专注于特定领域进行推理。这类似于混合专家模型(Mixture of Experts, Moe),但意图识别和 Moe 并不完全相同。
通过这些方法,我们可以有效地理解用户的意图并生成更加准确的响应。
需要准备这些数据
例句(多个):这些是用户可能输入的自然语言句子。这些例句用于训练和测试模型,使模型能够理解和识别不同的表达方式。例如,对于同一个意图“查询天气”,用户可能会输入“今天天气怎么样?”、“明天会下雨吗?”等不同的句子。
分类名称:每个分类名称代表一个独特的意图。例如,“查询天气”、“预订餐厅”、“设置闹钟”等。将例句按分类名称分组,可以帮助模型学习不同意图的特征。
问题重写提示词:这些提示词用于重写用户的输入问题,使其更标准化和规范化。例如,将“今天天气怎么样?”重写为“请告诉我今天的天气情况”。这有助于减少输入的多样性,使模型更容易识别意图。
问题推理提示词:这些提示词用于帮助模型推理用户的实际需求。例如,对于“预订餐厅”意图,提示词可以是“用户想要预订一家餐厅”。这有助于模型在识别意图后,进一步推理用户的具体需求。
需要准备的数据示例
例句及分类名称:
{
"查询天气": ["今天天气怎么样?", "明天会下雨吗?", "下周的天气预报是什么?"],
"预订餐厅": ["我想预订一家餐厅。", "帮我找个吃饭的地方。", "预订晚餐。"]
}
问题重写提示词:
- 查询天气 问题重写提示器示例
You will be given a conversation below and a follow up question. You need to rephrase the follow-up question if needed so it is a standalone question that can be used by the LLM to search the web for information.
If it is a writing task or a simple hi, hello rather than a question, you need to return not_needed as the response.
Example:
1. Follow up question: 今天天气怎么样?
Rephrased: 请告诉我今天的天气情况
2. Follow up question: 明天会下雨吗?
Rephrased: 请告诉我明天的天气情况
Conversation:
#for(message : messages)
#(message.role): #(message.content)
#end
Follow up question: #(query)
Rephrased question:
- 预订餐厅 省略
问题推理提示词:
{
"查询天气": "请根据我的提供的API接口查询 北京市 2024/07/13天气信息.并通过这些数据回答用户的问题",
"预订餐厅": "请根据我的提供的API接口查询 北京市 海淀区 泰兴大厦附件的餐厅信息.并通过这些数据回答用户的问题"
}
意图识别实现
数据设计
为了实现意图识别,设计了两张数据库表:rumi_intent_classification
和 rumi_intent_question
。
rumi_intent_classification
表:用于存储意图分类的相关信息,包括意图的名称、描述、操作、提示信息、附加信息等。rumi_intent_question
表:用于存储每个意图分类的具体例句,以便训练和识别不同的意图。
以下是表的结构:
CREATE TABLE rumi_intent_classification (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR,
description VARCHAR,
action VARCHAR,
prompt VARCHAR,
additional_info VARCHAR,
include_general SMALLINT NOT NULL DEFAULT 1,
remark VARCHAR(256),
creator VARCHAR(64) DEFAULT '',
create_time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(64) DEFAULT '',
update_time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted SMALLINT NOT NULL DEFAULT 0,
tenant_id BIGINT NOT NULL DEFAULT 0
);
CREATE TABLE rumi_intent_question (
id BIGSERIAL NOT NULL PRIMARY KEY,
question VARCHAR,
question_vector vector(3072),
category_id BIGINT,
remark VARCHAR(256),
creator VARCHAR(64) DEFAULT '',
create_time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(64) DEFAULT '',
update_time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted SMALLINT NOT NULL DEFAULT 0,
tenant_id BIGINT NOT NULL DEFAULT 0
);
rumi_intent_classification
表包含以下字段:name
:意图的名称。additional_info
:附加信息,识别到这个意图后将这些附加信息发送到大模型。- 其他字段包括创建者、更新时间、租户 ID 等。
rumi_intent_question
表包含以下字段:question
:用于识别意图的具体问题或例句。question_vector
: 存储向量,用相似度计算category_id
:关联到rumi_intent_classification
表,表示该问题属于哪个意图分类。
初始数据
假设将意图分为三个分类:course_registration_and_enrollment
、financial_aid_and_tuition
、campus_services_and_resources
。我们可以为这些意图分类插入一些初始数据。
插入意图分类数据
假设将意图分为 3 类,添加 3 个分类分别是
- course_registration_and_enrollment
- financial_aid_and_tuition
- campus_services_and_resources,
-- Insert statements for rumi_intent_classification
INSERT INTO "public"."rumi_intent_classification" VALUES (1, 'course_registration_and_enrollment', '', '', '', 'You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process.', 1, '', '', '2024-08-03 06:48:36.702311', '', '2024-08-03 06:48:36.702311', 0, 0);
INSERT INTO "public"."rumi_intent_classification" VALUES (2, 'financial_aid_and_tuition', '', '', '', 'you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible.', 1, '', '', '2024-08-03 06:48:36.702311', '', '2024-08-03 06:48:36.702311', 0, 0);
INSERT INTO "public"."rumi_intent_classification" VALUES (3, 'campus_services_and_resources', '', '', '', 'you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible.', 1, '', '', '2024-08-03 06:48:36.702311', '', '2024-08-03 06:48:36.702311', 0, 0);
这三个意图分类涵盖了常见的学生需求,包括课程注册、经济资助和校园服务等。
插入意图例句数据
为每个意图分类编写一些例句,并插入到数据库中:
-- Insert statements for rumi_intent_question
INSERT INTO rumi_intent_question (question, category_id, remark)
VALUES
('How can I enroll in a class that is full?', 1, ''),
('What is the process for registering for summer classes?', 1, ''),
('Can I drop a course after the deadline?', 1, ''),
('How do I register for classes at SJSU?', 1, ''),
('Is there a way to get into a waitlisted class?', 1, ''),
('When does enrollment for the next semester open?', 1, ''),
('How many units can I take in one semester?', 1, ''),
('What are the prerequisites for enrolling in upper-division courses?', 1, ''),
('Can I take a class without meeting the prerequisites?', 1, ''),
('How do I switch my major?', 1, ''),
('How do I apply for financial aid?', 2, ''),
('What are the deadlines for submitting financial aid applications?', 2, ''),
('Can I get a refund if I drop a class?', 2, ''),
('How do I set up a payment plan for my tuition?', 2, ''),
('What scholarships are available for SJSU students?', 2, ''),
('How do I check the status of my financial aid application?', 2, ''),
('Are there any grants available for part-time students?', 2, ''),
('What is the cost of tuition for out-of-state students?', 2, ''),
('Can I appeal my financial aid award?', 2, ''),
('How do I pay my tuition fees online?', 2, ''),
('Where can I find the campus bookstore?', 3, ''),
('How do I access the student health center?', 3, ''),
('What services does the career center offer?', 3, ''),
('Is there a gym on campus for students?', 3, ''),
('How can I get technical support for my student account?', 3, ''),
('Where is the counseling center located?', 3, ''),
('What resources are available for international students?', 3, ''),
('How do I get a student parking permit?', 3, ''),
('Are there any free tutoring services available?', 3, ''),
('Where can I print documents on campus?', 3, ''),
这些例句涵盖了学生在不同场景下可能会提出的问题,以便更好地训练意图识别模型。
查询数据
我们可以通过以下 SQL 查询来检索分类和相关问题数据:
SELECT
rumi_intent_classification.id,
rumi_intent_classification.name,
rumi_intent_classification.action,
rumi_intent_classification.additional_info,
include_general,
rumi_intent_question.question
FROM
rumi_intent_question
LEFT JOIN rumi_intent_classification ON rumi_intent_question.category_id = rumi_intent_classification.id
WHERE
rumi_intent_classification.id IN (1, 2, 3);
此查询将返回三个意图分类(course_registration_and_enrollment
、financial_aid_and_tuition
、campus_services_and_resources
)及其相关的所有问题,以便在意图识别的过程中提供参考。
查询到的数据示例如下
id | name | action | additional_info | include_general | question |
---|---|---|---|---|---|
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | What is the process for registering for summer classes? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | Can I appeal my financial aid award? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | How can I get technical support for my student account? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | Can I drop a course after the deadline? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | Is there a way to get into a waitlisted class? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | When does enrollment for the next semester open? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | How many units can I take in one semester? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | Can I take a class without meeting the prerequisites? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | How do I switch my major? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | How do I apply for financial aid? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | What are the deadlines for submitting financial aid applications? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | Can I get a refund if I drop a class? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | How do I set up a payment plan for my tuition? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | How do I check the status of my financial aid application? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | Are there any grants available for part-time students? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | What is the cost of tuition for out-of-state students? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | How can I enroll in a class that is full? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | How do I register for classes at SJSU? | |
1 | course_registration_and_enrollment | You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process. | 1 | What are the prerequisites for enrolling in upper-division courses? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | What scholarships are available for SJSU students? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | How do I access the student health center? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | What resources are available for international students? | |
2 | financial_aid_and_tuition | you need to provide detailed step-by-step instructions to guide students through applying for financial aid, scholarships, payment plans, or any related funds in the corresponding university. Including links to the documents they need to fill out if possible. | 1 | How do I pay my tuition fees online? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | Where can I find the campus bookstore? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | What services does the career center offer? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | Is there a gym on campus for students? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | Where is the counseling center located? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | How do I get a student parking permit? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | Are there any free tutoring services available? | |
3 | campus_services_and_resources | you need to provide detailed responses for students who seek for campus facilities, health services, career services in the corresponding university, or any related resources. Provide a link to related campus website if possible. | 1 | Where can I print documents on campus? |
向量化
调用 OpenAI 的接口,将例句向量化,方便后续的的 余弦相似度计算,向量化的示例代码如下
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.postgresql.util.PGobject;
import com.litongjava.db.activerecord.Db;
import com.litongjava.db.activerecord.Record;
import com.litongjava.db.utils.PgVectorUtils;
import com.litongjava.open.chat.config.DbConfig;
import com.litongjava.open.chat.constants.TableNames;
import com.litongjava.openai.client.OpenAiClient;
import com.litongjava.openai.constants.OpenAiModels;
import com.litongjava.openai.embedding.EmbeddingRequestVo;
import com.litongjava.openai.embedding.EmbeddingResponseVo;
import com.litongjava.tio.utils.environment.EnvUtils;
import com.litongjava.tio.utils.hutool.StrUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class IntentEmbeddingTest {
@Test
public void intentEmbedding() {
EnvUtils.load();
new DbConfig().config();
String selectSql = "select id,question from " + TableNames.rumi_intent_question + " where question_vector is null";
List<Record> records = Db.find(selectSql);
String updateSql = "update " + TableNames.rumi_intent_question + " set question_vector= ? where id=?";
for (Record record : records) {
Object id = record.get("id");
String question = record.getStr("question");
if (record.get("question_vector") != null) {
log.info("skip:{},{}", id, question);
continue;
}
if (StrUtil.isEmpty(question)) {
log.error("please check the data:{},{},{}", TableNames.rumi_intent_question, id, question);
continue;
}
EmbeddingRequestVo reqVo = new EmbeddingRequestVo(question, OpenAiModels.text_embedding_3_large);
EmbeddingResponseVo embeddings = OpenAiClient.embeddings(reqVo);
float[] embeddingArray = embeddings.getData().get(0).getEmbedding();
String string = Arrays.toString(embeddingArray);
log.info("text:{},vector:{}", string);
PGobject pgVector = PgVectorUtils.getPgVector(string);
int update = Db.updateBySql(updateSql, pgVector, id);
if (update < 1) {
log.error("update fail:{},{},{}", TableNames.rumi_intent_question, id, pgVector);
}
}
log.info("finished embedding rumi_intent_question");
}
}
测试向量相似度-SQL 示例
编写一条 sql,测试能否计算出向量相似度 查询 SQL 示例
SELECT
rumi_intent_classification.id,
rumi_intent_classification.name,
rumi_intent_classification.action,
rumi_intent_classification.additional_info,
rumi_intent_classification.include_general,
rumi_intent_question.question,
(1 - (rumi_intent_question.question_vector <=> input.input_vector)) AS similarity
FROM
rumi_intent_question
LEFT JOIN rumi_intent_classification ON rumi_intent_question.category_id = rumi_intent_classification.id,
LATERAL (
VALUES ('[-0.029234013,0.0061625354,-0.008342916,0.038780365,-0.013697527,-0.03147862,-0.021242661,0.08199586,0.009262395,-0.0008806036,0.008951395,-0.051193327,0.009674808,0.0050638933,-0.033885494,0.003224936,-0.02016092,0.04486515,-0.028936533,0.010296809,-0.017402485,0.03604897,-0.018443659,0.07263881,-0.0054999697,-0.011730114,0.024203923,0.017483616,-0.006402546,0.0021600986,0.03667097,0.030910708,0.07464003,-0.0041275127,0.0002695898,0.035886712,0.0011180793,0.023744185,-0.031722013,0.011966744,-0.049787063,0.0068555246,0.040240712,0.07307151,0.018971007,-0.04102497,0.01782166,-0.028422708,0.03277671,0.01759179,-0.034534536,0.0537895,0.027990011,-0.0018355768,0.009282677,-0.014116702,-0.018267877,0.034913145,-0.021972835,0.0045128823,-0.0021499575,0.005570959,-0.013596115,-0.024528446,0.03997028,0.005665611,0.023068096,0.033452798,-0.01302144,-0.019025095,0.032993056,-0.016604703,0.009417895,-0.020350225,-0.00027212512,-0.008789134,-0.0034446644,0.006547905,-0.064850286,-0.007267938,-0.02068827,-0.046298455,-0.0023189792,0.015117311,-0.009485504,0.0038807408,0.02556962,-0.058846634,-0.0049591,0.014535876,0.0020874194,-0.010668657,0.005587861,-0.043107323,0.036833234,0.026407968,0.025001707,0.019579487,-0.02853088,-0.03464271,-0.019160312,-0.02255427,0.020079792,-0.05176124,-0.010486113,-0.005743361,-0.007626264,0.019701183,0.01340681,-0.055601414,0.05387063,0.002077278,-0.012129005,0.016794007,0.0002581808,0.0037049581,-0.031208187,0.049732976,0.028044099,0.042593498,-0.005767024,-0.020242052,-0.0055067306,-0.013136375,0.0027144903,-0.012230418,0.029315142,-0.020025704,-0.008079243,0.00021022088,0.017023876,0.02132379,-0.054925326,0.009911438,0.004093708,-0.0030795773,-0.015009137,0.06128055,0.010770069,0.0062031006,-0.02496114,-0.0067439703,-0.019254964,-0.017267268,-0.010999939,-0.013886832,0.011419114,-0.008424047,0.014576441,0.010952613,0.020201487,0.0012372397,0.01387331,0.02262188,0.025461445,0.008464612,0.013555549,0.014535876,-0.0019860063,-0.012669875,-0.012521136,0.018889878,-0.013690767,0.02410927,-0.03256036,-0.014982093,0.0013859789,-0.0026418108,0.02131027,-0.003502132,0.006882568,-0.0136231575,-0.0020434738,-0.009620721,0.023541357,-0.0108173955,0.015225485,0.0060205567,-0.026178097,-0.009945244,-0.030045317,0.050030455,-0.0059563285,-0.004424991,0.0015989463,-0.023527836,0.013055244,-0.014089658,-0.00983707,-0.0556555,0.009782982,0.005672372,0.049110975,0.018727617,0.01968766,-0.018321965,0.036211234,0.012730722,0.007788525,0.025772445,-0.038482886,-0.013846267,-0.02410927,0.009823548,-0.011554331,0.021026313,0.016455963,0.023149228,0.031343404,-0.022108052,-0.016063834,-0.019971617,-0.013183701,0.000960889,-0.016794007,0.029856013,0.036238275,0.011838287,0.008004873,-0.016293703,0.0173484,-0.039023757,-0.011432636,0.01642892,0.009438178,-0.011182483,0.008937873,-0.025907664,0.036941405,-0.03813132,0.026597273,-0.02750323,-0.004370904,0.012913266,0.030261666,-0.006389024,-0.034507494,0.021431966,-0.010202156,-0.009782982,0.03750932,-0.020674748,-0.015374224,-0.0073490683,-0.037942015,-0.007058351,0.007173286,0.056791328,-0.017794617,0.06317359,0.009870874,-0.0025471586,-0.025218055,0.029639665,0.0051112194,-0.029206969,-0.014211354,0.021486053,0.014319528,0.030721404,0.0073963944,0.0065850895,0.0034345232,-0.019011574,-0.0014290794,0.025867097,-0.017064441,0.04627141,0.022067487,-0.011757157,-0.026718969,-0.0147116585,0.045541238,0.012541418,0.0018406475,-0.056250457,-0.040402975,0.042214885,0.039862104,-0.005983372,0.019633573,0.058251675,0.0210804,-0.023000488,0.004117371,-0.015036181,-0.0069636987,0.0021668596,-0.010952613,0.008248264,-0.028233403,-0.03564332,0.013359484,0.016320746,0.022419052,0.012811854,-0.016996833,0.033912536,-0.015482398,-0.03610306,0.014319528,0.02820636,-0.019917531,-0.03742819,-1.37726365e-05,0.007153003,0.01634779,-0.063660376,-0.017781094,-0.024555488,0.044594713,-0.043215495,0.03247923,-0.010377939,0.044784017,-0.0036745341,0.012683396,-0.017456573,-0.018592399,-0.012216897,0.027368011,0.0014316147,-0.013379767,0.00025775825,0.028476795,0.014982093,0.0075316117,-0.053032283,0.023460228,-0.039618712,-0.021999879,-0.010202156,-0.033939578,0.0330201,0.010053418,-0.024298575,0.011419114,0.057494458,0.016496528,0.010932331,0.029747838,-0.021607747,0.02556962,-0.024433794,-0.012041113,0.024379706,0.062362287,-0.0048069805,0.028314533,0.031018883,0.00061481685,0.00039720125,0.056250457,-0.054979414,0.050030455,0.020823486,-0.0030102783,-0.031911317,0.0011552641,0.0037117188,-0.00040924406,-0.037942015,0.054032892,0.008545742,-0.012419723,-0.029179925,0.02379827,0.021269705,0.017781094,-0.012000549,-0.01967414,0.013305397,0.018186746,0.0023257402,-0.020647705,-0.041890364,-0.0037928494,0.01605031,-0.032830797,-0.0075856987,0.012142527,0.045622367,0.013548789,-0.0030085882,0.01967414,-0.010546961,0.03147862,0.00906633,-0.05781898,-0.0016859926,-0.0061591547,0.015901571,-0.018186746,0.012460288,0.035048362,-0.007308503,0.017388964,0.016104398,0.029071752,0.017632356,-0.03642758,0.010607809,-0.012068157,0.01628018,-0.01587453,0.055222806,-0.0223244,-0.022540748,0.0036846756,0.01968766,0.0031742295,0.03672506,0.012183092,-0.01852479,0.0346968,0.015036181,-0.015130833,0.02782775,0.0030373218,0.030288707,-0.00089159,0.03512949,-0.024447314,0.020877574,0.03859106,0.04743428,-0.03231697,0.007856133,0.0040260996,0.017456573,-0.025393836,-0.013927397,0.039267145,-0.01092557,0.03245219,0.007734438,0.022878792,0.044675846,-0.016699355,0.015333659,-0.04497332,0.012379157,-0.021256182,-0.012872701,-0.031586796,0.004198502,0.003525795,0.025042271,-0.004965861,0.03464271,-0.03610306,0.020715313,0.0074369595,-0.005787307,0.009749178,-0.0032215556,0.025326228,-0.016983312,0.028152272,-0.01634779,0.034534536,-0.0101886345,0.02642149,-0.0009879324,-0.03726593,0.035372883,-0.033290535,-0.008207699,0.004688665,0.033642102,0.062254112,0.00048382493,-0.015617616,0.050652456,-0.0055202525,0.01642892,-0.060956024,-0.01657766,-0.0011763918,0.008883786,-0.03929419,0.04610915,0.00016500754,0.014630528,0.026664881,-0.0037962298,-0.047055673,-0.006192959,-0.004326958,0.011594896,-0.003363534,0.010114265,-0.0022209466,-0.0021212236,-0.006936655,-0.010398222,0.032425143,0.003108311,0.01340681,0.0004665002,-0.038239494,0.011919418,0.025596663,0.021594226,-0.052031673,-0.0025539196,0.009904678,0.0013048484,0.005574339,0.0046582413,0.026867706,-0.03672506,0.005990133,-0.009627482,-0.012527896,0.010898526,0.003279023,0.0046514804,0.009620721,0.0035460775,-0.0065445243,-0.023744185,-0.0071259593,-0.011121635,-0.011567852,0.0040091975,0.013744853,-0.02828749,-0.0054154587,0.034507494,-0.0020975606,0.01867353,0.008200938,0.039402366,0.0065445243,0.011196004,-0.047163844,0.031722013,-0.0013352723,-0.00064524077,-0.033344623,-0.0077141556,0.0008501797,-0.03402071,-0.016848095,0.0018609301,0.025556097,-0.0008645466,-0.0201474,0.0039584907,0.031208187,0.005936046,-0.015374224,0.01719966,0.0009989189,0.024379706,-0.036157146,0.037563406,-0.019173834,0.006341698,0.011297418,-0.036833234,-0.033885494,0.0046447194,-0.002131365,-0.007633025,-0.043377757,0.05727811,0.00028923858,-0.008849982,-0.011574614,-0.0037421428,0.0034919905,-0.0059090024,0.03310123,0.023649532,0.04107906,0.0016082425,0.004888111,-0.019268487,-0.019187355,0.018943964,0.004330339,-0.019782312,-0.048543062,0.011365026,-0.009215069,-0.028774273,-0.0075924597,-0.00012919605,0.02309514,-0.0058549154,0.006230144,-0.00088229385,-0.016469484,0.006307894,0.0017561367,0.0121357655,-0.007301742,-0.0045737303,-0.012879462,0.014143745,-0.013771897,0.011527288,-0.014238398,0.013859788,0.009302961,-0.0065850895,-0.01371781,0.018957486,-0.022838227,-0.010208917,-0.037536364,0.016550615,-0.034291144,0.023460228,0.0013842887,0.0039246865,-0.021675358,-0.016077355,-0.033425752,0.045757584,-0.016969789,0.00021782686,0.011283896,0.04905689,0.008613352,0.013433853,0.006314655,-0.03418297,-0.011121635,-0.02596175,0.0111622,0.013967962,-0.026705446,-0.014617006,-0.012007309,0.02424449,-0.025799489,-0.021256182,-0.040051408,0.0109864175,0.0095598735,0.04362115,-0.013582593,-0.0108782435,0.012933549,-0.019958096,-0.010743027,0.0346968,0.03147862,0.0018220551,0.03542697,0.022108052,0.0072814594,0.0015693675,0.027935924,0.008890547,0.0027094197,-0.015658181,-0.053302716,0.00248124,-0.007166525,-0.012886222,-0.02145901,-0.034940187,0.038455844,0.0016293703,-0.014062614,0.022703009,0.0046244366,0.00092961994,0.016956268,0.0017054301,0.013440615,-0.026448533,-0.0028784415,0.030883664,-0.014427702,0.0037962298,-0.0002053615,0.005881959,0.010803874,0.0152795715,0.01999866,-0.014306006,0.02068827,0.011953223,-0.009120417,0.033452798,0.020201487,0.030180534,0.00030508437,-0.0011679407,0.00032473315,-0.017848704,0.008464612,-0.024393227,0.0075180903,-0.024352662,-0.0073355464,0.014292484,0.0001788462,0.045919847,0.010445548,-0.0035765015,-0.0019927672,0.01177744,0.016726399,0.009627482,-0.002520115,0.012581984,0.0007293291,0.030099403,0.014360093,0.00071961037,0.02674601,-0.008964917,-0.016766964,-0.012352114,0.008349678,-0.013291875,-0.00868096,-0.00092285906,-0.013373005,0.024298575,0.0137921795,-0.014400658,-0.026570229,0.012061397,0.03099184,-0.003519034,0.03356097,-0.0073963944,0.022108052,-0.009566634,-0.020187965,0.008741808,0.01659118,0.0059698503,0.017132051,0.0046176757,0.033750273,0.02101279,0.0015296474,-0.020444877,0.028233403,-0.0440268,0.022675967,-0.0032131046,-0.0006870737,-0.039618712,0.03185723,-0.011696309,0.00010246947,-0.006672981,-0.008248264,-0.015631137,-0.027029967,0.010100744,0.014873919,0.00021497461,0.01139883,0.021229139,0.0010115955,0.022446096,-0.021053357,-0.008924352,0.0053106654,0.0016766964,0.006625655,-0.014603484,0.005185589,-0.0028615391,-0.014860397,0.009647765,-0.016699355,0.011135157,0.020972226,-0.038212452,0.0008320099,-0.016320746,0.0031269034,0.005767024,-0.0045669693,-0.014373614,0.0036880558,-0.0068791877,0.008167134,0.04391863,0.0023544738,0.030423926,0.020052748,-0.007004264,-0.009661287,0.0011282206,-0.011128396,0.028449751,-0.03575149,-0.03247923,0.04253941,-0.014170788,-0.0026908272,-0.0007563726,-0.009776222,0.01906566,0.029477404,0.00216855,-0.0046480997,-0.001123995,-0.022405531,-0.012987636,-0.014427702,0.040781584,0.022973444,-0.0059867525,-0.00030888736,0.015076745,-0.024068706,-0.038158365,0.020350225,0.006929894,-0.012500853,-0.005043611,0.033047143,0.054357413,0.0017257127,0.014062614,-0.011202766,-0.00635522,0.032344013,0.057764895,-0.030505056,0.02101279,0.019904008,0.008640395,-0.013312158,0.020269096,0.0033922677,0.04494628,0.0367521,0.005652089,0.022730052,0.036833234,0.007153003,0.010952613,-0.02828749,0.011811244,0.013400049,-0.011365026,0.032533318,0.032344013,0.0036136862,0.024650142,-0.03572445,0.018294921,0.024731271,-0.03439932,0.01968766,-0.000596647,0.010377939,0.011601657,0.029071752,-0.0053884154,-0.009985808,0.0002062066,0.03256036,-0.0059225243,-0.010905287,-0.00434048,0.010513157,0.0087012425,-0.015144354,0.017294312,-0.019944573,0.010722743,-0.014589963,0.031181144,0.01929553,-0.0013141446,0.038482886,0.01271044,-0.025488488,-0.016604703,0.031343404,-0.0030322513,-0.02782775,-0.021945791,-0.049489588,0.0013969652,-0.015144354,0.03331758,-0.03829358,-0.005936046,0.026096968,0.013305397,-0.022364967,-0.009505787,-0.025758924,0.0023696858,-0.0074572423,0.008998721,0.036914364,-0.02101279,0.018903399,-0.010776831,0.008261786,-0.02394701,0.0046311975,-0.004448654,0.010276526,0.009120417,-0.035697408,0.0015051392,0.01263607,-0.022405531,-0.0004291041,-0.004712328,0.023730662,-0.011540809,0.015631137,0.02519101,-0.0060036546,0.04813741,0.013535267,-0.00047959937,0.0045669693,-0.0022648922,-0.0030221099,-0.0066865026,0.008633634,0.021526618,0.019890487,-0.004502741,-0.007862895,-0.015685223,-0.021540139,0.016063834,0.0074978075,0.007795286,-0.01999866,0.02147253,0.008782373,0.011561092,-0.0085187,0.0061861984,-0.0005163616,0.016374832,-0.0067101656,-0.0016665551,0.025123402,-0.0040328605,0.0012186472,0.017713485,0.007044829,0.02488001,-0.018389573,0.006260568,-0.017875746,0.025948228,-0.01015483,0.023987575,-0.0007204555,0.010655135,0.03280375,-0.016090875,0.0075586555,-0.0022936258,0.022567792,-0.019863443,-0.0047157086,0.015293093,0.052518457,-0.014914485,-0.007930503,0.013366245,0.026840663,-0.011256852,-0.017443052,0.0042120237,-0.010087222,0.0012347043,-0.003471708,0.015414789,0.03277671,-0.018862834,-0.012331831,0.0031353545,-0.0079034595,0.026124012,0.006558046,-0.0041275127,-0.004790078,-0.060847852,-0.04976002,-0.012101961,-0.00828883,-0.010810635,-0.019904008,-0.011581374,0.0038334148,0.0018440279,0.016848095,-0.0019623432,0.004928676,-0.001433305,-0.004242447,-0.025948228,-0.014035571,0.007044829,0.022121575,-0.026124012,0.004472317,-0.011912657,0.019944573,0.00069552474,-0.04253941,0.018321965,-0.0142519185,0.0017409247,-0.012764527,-0.008843221,-0.020390792,-0.009363809,-0.008018395,-0.0067710136,0.012967354,0.0011231499,0.00496248,-0.027719576,0.0073828725,0.008593068,-0.0005100233,-0.003519034,-0.007044829,0.0396728,-0.0034581863,0.04364819,-0.010263004,0.008180656,0.02101279,0.0037590452,0.005185589,0.021337314,-0.016253138,-0.024596054,0.03293897,-0.0047021867,-0.034859058,0.003209724,-0.0014611935,0.006929894,0.011479962,-0.016293703,0.00020768555,-0.012764527,-0.0031556373,-0.008221221,0.015117311,-0.00828883,-0.027597882,0.011297418,-0.019200878,0.020782921,-0.0016454273,0.028341576,0.00154993,0.008566026,0.0007314419,0.013217505,0.015157876,-0.0067507313,0.01317694,-0.008735047,0.010398222,-0.017929833,-0.034210015,-0.00014947866,-0.02216214,-0.018971007,0.027773663,-0.010121026,-0.026827142,0.02147253,-0.025637228,-0.029774882,0.002812523,-0.014860397,-0.015117311,-0.005804209,-0.023135705,0.011851809,-0.020052748,0.006263948,0.012453527,0.0054458827,0.005851535,0.051031064,-0.003238458,-0.007815569,-0.027530272,-0.008207699,-0.014116702,0.042593498,0.023568401,0.042485323,-0.02440675,0.034453407,0.001054696,-0.016415399,-0.0198364,0.004228926,-0.0026333597,-0.024920575,-0.017077964,-0.0067743943,0.034940187,-0.0036745341,-0.013460897,0.019363139,0.042458277,-0.009776222,0.0027094197,-0.0061354917,0.02642149,-0.0039348276,-0.02185114,0.0232574,0.014508832,0.011148678,-0.018741138,-0.0068149595,0.025813011,-0.024366183,-0.014116702,0.011987027,0.0027415338,-0.027881838,0.015360702,-0.035589233,0.012541418,0.02162127,-0.004059904,0.0066357963,0.00026705445,-0.030883664,0.0030373218,-0.000724681,0.007923743,-0.013839506,0.0060070353,-0.03969984,-0.0173484,-0.0037083386,-0.0008594759,-0.0023206694,0.011189244,0.012568462,0.026462054,-0.0044385125,-0.023149228,-0.013109332,0.024447314,0.0057230783,0.025393836,-0.05408698,0.002440675,-0.00016363423,0.018849311,0.013454136,0.020201487,-0.0192144,-0.02060714,0.0045906324,0.0016023268,-0.0018119138,-0.023419661,-0.017727008,0.0046480997,0.016388355,-0.0030761969,0.003897643,-0.0010132857,0.005699415,-0.0024761695,0.02596175,0.030099403,0.0024389848,-0.0039720125,-0.027597882,0.02185114,-0.001395275,0.0022970063,0.04518967,0.008113047,0.001233014,0.038834453,0.039835062,0.005790687,0.009228591,0.008153612,0.040862713,-0.018173225,0.017429529,-0.008031917,0.005168687,0.022067487,0.018200269,0.00814009,0.0033111372,-0.0055608177,0.008863504,-0.017388964,0.036914364,-0.008302351,0.012000549,0.0051822085,-0.008336156,0.031938363,0.01371781,-0.022175662,-0.003495371,-0.006290992,-0.0053039044,0.023595445,0.021607747,0.020553052,0.008025155,0.0054053175,0.0017476855,-0.0059799915,-0.005456024,-0.013602875,0.00012644943,0.005743361,0.019430747,0.014360093,0.0075992206,0.011196004,-0.007369351,0.012933549,0.0038334148,0.0012347043,0.01418431,0.023595445,0.01673992,-0.004330339,0.001735854,0.015428311,-0.03512949,0.009755939,0.030180534,-0.018240834,0.009478743,-0.00906633,-0.013785419,0.0096072,0.014035571,0.00713272,-0.0054154587,-0.0076465467,-0.0053309477,0.0025319466,0.012717201,0.01146644,-0.007862895,-0.00814009,0.019403704,-0.007524851,0.0012499163,-0.010195396,-0.010222439,0.015117311,-0.0024119413,0.005709557,0.03307419,-0.0038232733,0.00774796,-0.031884275,-0.0018998052,-0.017929833,-0.025745401,-0.00023367265,0.0076059815,0.012960592,-0.026096968,0.028260447,0.023000488,0.0030981698,0.008437568,0.014833354,0.00983707,-0.010614569,-0.0062369048,-0.008491656,0.024176879,0.018538313,-0.02627275,-0.02022853,0.036562797,-0.0226354,-0.020471921,0.0054458827,-0.0040024365,-8.8577995e-05,-0.00057763205,0.013312158,-0.0007665139,-0.015658181,0.02279766,0.014157266,-0.017483616,-0.0170374,-0.006372122,-0.002518425,-0.015468876,0.02442027,-0.0034531155,0.035318796,-0.00042572367,0.010702461,-0.039023757,-0.0050943173,0.017388964,-0.026232185,-0.0045230235,-0.008092764,0.0009321553,0.024122793,0.0037691863,-0.01449531,-0.019931052,-0.008126569,0.009032525,-0.018159702,0.027489707,-0.0004255124,-0.02177001,-0.001178082,0.010006092,-0.03155975,-0.031505667,-0.00012021676,0.031992447,-0.025245098,-0.016266659,-0.017564746,0.014035571,0.023365576,0.01387331,-0.021418443,-0.0074842856,-0.0057704044,-0.031100012,0.005763644,-7.019687e-05,-0.014928007,-0.02185114,-0.0133932885,0.022432575,0.012669875,0.014589963,0.021607747,-0.013312158,0.021377878,-0.001309919,0.0035832624,-0.014427702,-0.031181144,0.004448654,-0.0029359087,0.006456633,-0.024582531,0.008566026,-0.0011696309,-0.013183701,0.00015761284,-0.0028344959,0.026326837,0.033425752,-0.02348727,-0.012223657,-0.0026012457,-0.012575222,0.009681569,0.024217445,0.007308503,-0.0029832348,0.027368011,-0.013609636,0.00096342433,-0.00010727603,0.0125346575,-0.013325679,0.008964917,0.036562797,0.025691316,0.03572445,0.00859983,0.0006942571,0.017470093,0.0036779146,0.0074234377,0.035372883,-0.025380315,0.030234622,0.009431417,-0.01162194,0.0029156262,-0.032533318,0.013089049,-0.0037691863,-0.0072814594,-0.0008721525,-0.002837876,-0.015996223,-0.0054154587,0.0066865026,-0.005662231,-0.063444026,0.009133939,0.012115483,2.7915008e-05,-0.0044148494,0.012264223,-0.020877574,0.0040430017,-0.019755268,0.015793398,-0.013487941,-0.017767573,-0.00635522,0.01255494,-0.0029815447,-0.025596663,0.00081468513,-0.0017324735,0.0024981424,0.0065681874,-0.0075383727,0.011763918,-0.01719966,-0.008234742,0.016780484,0.018470703,0.011446157,0.024339141,0.013758375,0.015306615,0.012494092,0.0072341333,0.011270374,-0.0074369595,0.0030778872,0.03672506,0.008052199,0.0029122457,0.02371714,0.012223657,-0.010533439,-0.0065377634,-0.008282069,-0.017740529,0.019620052,0.0024322239,0.047326107,0.010634853,-0.0037083386,-0.018403094,-0.0031184524,0.018173225,0.004908393,0.0039382083,0.009127177,-0.007315264,0.00023029222,-0.03169497,-0.005026709,-0.002077278,0.0015634517,-0.001425699,0.0048407847,0.0042661102,-0.009850591,0.006145633,0.009647765,0.020864053,-0.0061490135,0.024852967,0.0020062889,0.011730114,0.022986965,0.013616397,0.0113177,0.013143136,-0.031938363,0.021486053,0.030018274,-0.01572579,-0.008038677,0.0035055124,-0.02262188,-0.0020130498,0.007829091,-0.016645268,0.0029477403,-0.019119747,-0.016320746,-0.011128396,-0.011696309,0.0005201646,-0.014995615,-6.1428866e-05,-0.00883646,0.016956268,-0.004918535,0.0022023541,-0.003860458,0.0024626479,0.00581097,0.0067574917,-0.006950177,0.010202156,-0.008275308,0.019782312,0.0068115788,-0.008403764,-0.008086003,-0.016063834,0.025826532,0.0013369626,0.00891083,-0.035156537,-0.01628018,-0.0110067,-0.035562187,-0.0076600686,0.0037590452,0.0317761,-0.018078573,0.008430808,-0.018578878,-0.019876964,0.02394701,0.0103847,0.014576441,-0.013582593,-0.009566634,0.01549592,-0.00224799,0.02782775,-0.0059867525,4.32062e-05,-0.030721404,0.011412352,0.0017814898,-0.011642222,0.003246909,-0.0087012425,-0.01665879,-0.009350287,-0.0067777745,0.0064363503,0.005074035,0.020715313,0.010972896,0.01603679,-0.014008528,-0.0025826532,-0.0033787459,0.022905836,0.003884121,0.029152881,-0.036562797,-0.015414789,0.01628018,-0.012581984,-0.011331222,-0.0046582413,0.01572579,0.015604094,-0.0065377634,-0.0043675234,-0.026245706,0.019593008,0.016483007,-0.013738093,-0.00029747837,0.003789469,-0.030396882,0.0037421428,-0.004992904,-0.01092557,-0.003084648,0.0034987514,0.009877634,0.0080724815,-0.0018643106,-0.0054256,0.005239676,0.018768182,-0.0099182,0.0060273176,-0.00581097,-0.015049702,0.0066526984,-0.0035055124,-0.005905622,-0.008971678,-0.01603679,0.013440615,-0.00705159,-0.0058008283,-0.002386588,-0.02619162,-0.028098186,-0.0014882371,0.008248264,-0.008795895,-0.0018660008,-0.0030626752,-0.023730662,0.017740529,0.0114732,-0.0133324405,-0.019336095,0.0046379585,-0.011182483,0.0022496802,0.0018913541,0.009032525,0.02735449,0.008511938,-0.025502011,-0.0044655562,0.027990011,-0.0015752832,-0.012325071,3.861092e-05,0.022419052,-0.017808137,0.025285663,0.0039213058,0.016131442,0.0116760265,0.010830917,0.0033128276,-0.004076806,-0.017091485,0.012649592,-0.004059904,0.009722134,-0.005550676,0.006446492,-0.007247655,0.023460228,0.010100744,-0.0069231335,0.011953223,-0.01821379,-0.014170788,0.02371714,-0.0058244914,-0.0010563863,0.009823548,-0.0005881959,-0.0068724267,0.012412962,0.034669753,-0.008113047,4.8144808e-05,0.0020941803,0.004982763,0.009323243,0.009654526,-0.017159093,0.006372122,0.020323182,-0.0033331101,-0.008329395,-0.009634243,0.00015127452,0.0026147673,0.01673992,0.006368742,0.0045297844,-0.013548789,-0.021864662,0.01356231,-0.009019004,0.0022141857,-0.013643441,-0.0040632845,-0.0053917957,0.003277333,0.008099525,0.013312158,-0.003650871,0.0036711537,0.0096072,0.0072273724,-0.028747229,-0.011087831,-0.007768242,-0.0020417834,0.003294235,0.00992496,0.021905227,-0.0028040719,0.003603545,0.017064441,-0.009052808,-0.0047021867,0.01239944,-0.044432454,-0.009830308,-0.011033744,0.0014527425,-0.014116702,-0.004796839,0.040835667,-0.021729443,0.0029595718,-0.020066269,-0.0022344682,-0.0022175661,0.0054830676,-0.00034818493,0.021337314,0.02060714,-0.018227313,-0.007998112,-0.0019200877,0.014306006,0.010682179,-0.0024677184,-0.026651358,-0.00279055,-0.016969789,0.005540535,-0.009458461,-0.0093908515,-0.002814213,-0.028882448,0.015901571,-0.0005594622,0.008944634,-0.0044756974,0.0011544189,-0.0016978241,0.02899062,-0.009248873,-0.005138263,0.001014976,0.00020007956,0.010452309,-0.0029595718,-0.014914485,0.007416677,-0.007950786,-0.0010301879,-3.9007064e-05,-0.009884396,0.011209526,-0.008958156,-0.007802047,0.044594713,0.006889329,-0.026056401,0.010763309,-0.0013031581,0.004296534,0.03169497,0.033750273,-0.004191741,-0.009438178,0.0054458827,0.013170179,0.007876417,0.010486113,0.00036910138,0.004090328,0.0010107504,0.011128396,-0.041106105,-0.0036981972,-0.007524851,0.012007309,-0.016821051,0.0010428645,0.015685223,-0.009478743,0.007916981,-0.006487057,0.008511938,-0.0018524791,-0.012189853,-0.003216485,0.0077073947,-0.0030119687,-0.0060509806,-0.0009870874,0.012730722,0.006446492,0.000627916,0.00016099328,0.016239615,-0.018781703,-0.011270374,-0.012176331,-0.00705159,-0.0016851474,-0.015820442,-0.0074437205,0.017632356,0.0041410346,0.0039584907,-0.011432636,0.004354002,-0.04586576,-0.015036181,-0.024122793,0.007254416,-0.029071752,-0.019876964,0.0065850895,0.0005239676,-0.0030525338,0.032506276,0.0067743943,-0.008802656,-3.248388e-05,0.007105677,-0.02178353,0.025975272,0.036292363,0.018619442,-0.013413571,0.01263607,0.004222165,0.013663723,-0.010411743,0.007065112,-0.00039825763,-0.0070110247,-0.0025589901,-0.0009575086,0.01611792,0.0037624254,0.0120140705,0.015644658,0.012926788,0.011168961,-0.009262395,-0.0013048484,-0.0009127178,-0.023892922,0.0144817885,-0.0075518945,-0.019890487,0.009512547,-0.0016944436,-0.011642222,0.016848095,0.02099927,0.004411469,-0.0037996103,0.003160708,-0.0014966881,-0.027178707,0.0024677184,-0.028044099,0.022067487,-0.013427093,0.01611792,0.014671093,0.013183701,0.009985808,-0.026178097,0.0032688817,-0.010601048,-0.01154757,-0.011256852,0.011608418,-0.003884121,-0.009857352,-0.00814009,-0.000906802,0.010641613,-0.0004487529,-0.0020367128,0.026002316,-0.0046785236,-0.013819223,0.011196004,0.0033601536,-0.01278481,0.019755268,-0.015239006,-0.0094990255,-0.002371376,0.01262931,-0.0110472655,-0.027002925,-0.0002602936,-0.005787307,-0.007822329,-0.00845109,-0.0018693812,0.011980266,-0.007572177,-0.0005408698,-0.013345962,-0.018416617,0.004360763,0.019254964,-0.019593008,-0.0024677184,-0.006882568,-0.016604703,0.0026958978,-0.008309112,-0.018173225,0.004580491,-0.015482398,0.0074369595,-0.021499574,-0.0029359087,0.0009930031,-0.025529055,-0.00402948,-0.015969181,-0.014278962,-0.03945645,-0.011601657,0.0019437508,-0.030640274,0.0037049581,-0.0015059843,-0.0012896364,0.010371178,0.0030373218,-0.00036550965,0.012291266,-0.0052498174,-0.0075180903,-0.019931052,0.007065112,-0.013569071,0.019471312,-0.018727617,-0.0030778872,-0.016023267,0.013244549,-0.024596054,-0.014089658,0.013670484,-0.015982702,-0.013521745,0.020039225,0.01937666,-0.02882836,-0.01868705,0.0010394842,0.0133324405,0.00041093427,-0.006463394,0.024366183,0.0027601263,0.0045433063,-0.0217024,-0.001612468,-0.0024626479,0.010127787,0.00503685,-0.00720709,-0.020593617,-0.0023629249,-0.0018964247,-0.019200878,-0.012277744,0.02604288,0.011439396,0.013007918,-0.0067473506,0.002968023,0.019511878,0.016158486,0.015184919,7.347167e-05,0.012446766,0.020093312,0.022121575,-0.0019792453,-0.014076136,0.01557705,-0.0105402,0.012277744,0.012061397,-0.01131094,-0.016334267,-0.0013885142,-0.0132242665,-4.935965e-05,0.026083445,0.014076136,0.023906445,0.012061397,0.011020222,-0.016077355,-0.0075316117,-0.009133939,0.010121026,0.0016445823,-0.0024220825,0.015063223,-0.012176331,0.009654526,-0.004688665,-0.0092083085,-0.014549397,0.0022665826,0.004168078,-0.0068521444,0.009019004,0.009343525,-0.0023899684,-0.025474967,0.015387746,-0.006950177,0.00139443,-0.012277744,-0.015063223,-0.010601048,0.0017088105,-0.012007309,-0.013244549,-0.027570838,-0.028071143,0.010803874,0.0018845932,-0.013487941,0.020282617,-0.013278353,-0.00983707,0.0005370668,0.0019876964,0.006541144,-0.0015634517,0.011486722,-0.010438787,0.023419661,-0.0075316117,-0.00087130745,-0.007315264,0.019106226,-0.02542088,0.005689274,0.003199583,0.022959923,0.015644658,0.0001189491,-0.011669266,-0.009661287,0.009106895,-0.018497746,-0.017889269,-0.0061659156,-0.0044925995,-0.004999665,0.013285114,-0.016875137,0.0018507888,-0.009404373,0.000635522,-0.006858905,-0.0042120237,-0.005456024,-0.010472591,-0.010290048,-0.019038616,0.017970398,-0.027422098,0.005050372,-0.008552504,0.011574614,-0.032830797,0.010317091,-0.0011273755,-0.018173225,0.032533318,-0.019471312,0.016861616,0.027476186,-0.0054256,-0.010215678,-0.0034987514,0.022703009,-0.0094990255,0.010276526,0.0019741748,0.017294312,-0.0010631472,0.008099525,0.021337314,0.011040505,-0.016239615,0.0051957304,-0.017835181,-0.0034514253,-0.021878183,-0.0038334148,-0.022405531,0.0073896335,-0.014468267,0.0047393716,-0.018227313,0.0220134,0.030288707,0.01728079,-0.0035224145,0.013995006,-0.0073490683,0.003542697,0.021296749,0.0023426423,0.0053884154,-0.025123402,-0.00040755383,0.0031133818,-0.024203923,-0.007301742,-0.015482398,-0.0068487637,0.012933549,-0.013028201,0.02131027,-0.0041410346,-0.033533927,0.00992496,0.010553721,-0.0019944573,0.01092557,0.008904069,-0.017010355,-0.005821111,-0.008329395,0.0008687721,0.02720575,-0.021418443,-0.022743575,-0.007734438,-0.012818614,0.013596115,0.004448654,0.013197223,-0.0018169845,-0.02085053,0.012277744,0.014360093,-0.012683396,0.016455963,-0.022648923,0.016023267,-0.0114732,-0.015928615,0.013819223,0.011209526,-0.0220134,-0.014387136,-0.0018592399,0.0014755604,0.0127036795,0.0015930305,0.015536484,-0.0029325285,0.0020789683,-0.0029714033,0.007193568,0.015658181,-0.017118528,-0.029044708,-0.0017223322,-0.021418443,0.002062066,0.037184797,-0.012331831,0.0040362407,0.01937666,0.02882836,-0.0047089476,-0.005030089,0.0032266264,0.02030966,0.0008438414,0.021634791,-0.01798392,0.013805701,-0.0060949265,0.002417012,-0.022527227,-0.011371788,0.0062267636,0.013744853,0.032830797,0.0068487637,-0.01619905,-0.015806919,-0.0039922954,0.008572786,0.0067507313,-0.027219271,0.002905485,0.009012243,0.0015042941,-0.02114801,-0.0025049031,0.003556219,0.0029933762,0.0069096116,0.008356438,0.014522354,0.0118450485,0.0061794375,0.0075586555,0.018484225,-0.030775491,-0.025745401,-0.012487331,0.024163358,0.015063223,0.0059732306,0.0026773054,0.008809417,0.018335486,-0.008390242,0.01736192,-0.02602936,-0.0020519248,-0.01721318,-0.023108661,0.019444268,0.013271593,-0.004411469,-0.00627747,-0.00774796,-0.0032807132,-0.00697722,-0.019890487,0.0046075345,-0.008052199,0.007092155,-0.003904404,0.00828883,-0.023811793,-0.009133939,0.00821446,0.034669753,-0.014589963,0.0097627,-0.0091001345,0.0002797311,0.008802656,0.018660007,-0.00588872,-0.010993179,-1.9708207e-06,-0.034264103,0.018619442,0.0048475456,0.014684615,-0.010945853,0.011026983,-0.007815569,-0.016469484,-0.0044148494,0.016983312,0.002509974,0.00057636434,0.014982093,0.028612012,0.026069924,0.009512547,-0.031424534,-0.0013386527,0.012095201,-0.017416008,-0.007038068,-0.012744244,-0.0025792727,0.029477404,0.006443111,0.00067059405,-0.010026374,0.015833963,-0.004813741,0.013062006,-0.004354002,-0.017010355,-0.009580156,0.019741748,0.0024119413,-0.01255494,-0.013386527,0.033993665,0.01603679,-0.0201474,-0.002457577,0.014360093,0.018632965,0.010391461,0.016631747,-0.023189792,-0.022594836,0.007964307,0.005618285,0.047136802,-0.026800098,0.0054458827,0.0036069255,0.005101078,0.017402485,-0.03139749,-0.015049702,0.021296749,0.00023451776,0.02650262,-0.0024508163,0.017402485,0.015320137,0.00720709,0.004766415,-0.01914679,0.011223048,0.0129943965,-0.013913875,-0.008491656,-0.017537704,0.010932331,0.00027571683,0.00037227053,0.0062436657,0.018321965,0.0220134,-0.0019336095,0.031018883,0.0016893729,-0.015482398,0.012237179,-0.002263202,-0.009384091,-0.01534718,-6.3436e-05,0.0030711263,-0.00038220055,-0.0029899958,0.0019741748,0.009505787,0.004225545,0.02456901,-0.007031307,-0.0048644478,-0.0004143147,-0.011250092,-0.035318796,0.020647705,0.004790078,-0.019133268,0.015374224,-0.013028201,-0.011973505,0.002023191,-0.004580491,-0.020039225,0.024650142,-0.015036181,-0.013102571,0.0052667195,-0.00029663328,0.009357047,0.030478012,0.0027871695,0.020444877,0.016875137,-0.017429529,0.005929285,-0.023284445,-0.01805153,0.013467657,-0.008424047,-0.0019403704,0.0120749185,0.0037015777,-0.0034057894,-0.0067845355,-0.0009575086,-0.015076745,-0.01395444,-0.012385918,-0.00828883,-0.034210015,-0.0014197832,-0.015198441,-0.0060374592,-0.013305397,-0.0074775247,0.008566026,-0.00060002744,-0.0101886345,0.0009887776,0.02068827,0.011899135,-0.0065445243,-0.004932056,-0.003975393,-0.0020806585,-0.0052937632,-0.0033686047,0.0005459404,-0.008728286,0.022919357,-0.009742417,0.012325071,0.016604703,-0.009404373,-0.028801316,0.010722743,0.010661895,0.0029308381,0.0057366,0.00022606667,-0.012169571,0.004905013,0.015441832,-0.018578878,-0.0066831224,-0.0006980601,0.0003938208,-0.0063045137,0.024014618,0.0113177,-0.0019234682,-0.019119747,0.024704227,0.011331222,0.018876355,0.0120749185,0.0018254356,0.003681295,0.018781703,-0.013427093,-0.014914485,0.022594836,0.009803265,0.0048036,-0.03418297,-0.01852479,-0.010546961,0.0066357963,-0.010959374,0.012879462,-0.013217505,-0.0029646426,-0.0012127315,0.0062673287,-0.015401267,0.026705446,0.0064667743,-0.011824766,-0.028774273,-0.03502132,-0.0005788997,-0.0019910769,-0.0105875265,-0.024852967,-0.008478134,-0.0033669143,-0.009431417,0.008126569,0.013210745,0.002526876,-0.008633634,0.0014037262,-0.017010355,0.026759533,0.019349616,0.0016479626,0.011412352,0.011790961,0.0111622,0.008437568,-0.0012499163,-0.017645877,0.033290535,-0.0087620905,-0.024068706,0.011926179,0.013298636,0.009816786,0.003813132,-0.012494092,-0.018700574,0.0075518945,-0.017267268,-0.008667438,0.003999056,-0.024852967,0.0037759473,-0.0075924597,0.023122184,0.020972226,0.008092764,0.012723962,0.012980875,-0.017253747,-0.012081679,-0.00037586226,-0.003214795,-0.0054188394,-0.004360763,-0.023000488,0.016239615,-0.013650201,0.004347241,0.019079182,-0.01813266,-0.0035359364,-0.015090267,-0.018038008,-0.018484225,-0.0064363503,-0.0074640033,-0.003145496,0.004174839,-0.023974054,0.009661287,-0.0028412566,0.006348459,-0.0060611223,-0.011013461,0.011784201,0.039104886,0.0055371546,0.00046100697,-0.009201547,0.0058785784,-0.005547296,0.0062031006,-0.0060273176,-0.017145572,-0.004117371,-0.0021719302,0.009668048,0.009810026,0.019971617,-0.03231697,0.01999866,-0.0065850895,0.0064363503,0.016821051,0.024474358,-0.007193568,-0.0068284813,0.00937733,0.013203984,-0.0033905774,-0.002650262,0.009384091,0.0020891095,0.021026313,0.016969789,0.00836996,-0.0052092522,0.007146242,-0.017402485,-0.012358875,-0.012041113,-0.039943233,0.0024018,-0.013521745,-0.0034074797,0.008004873,-0.011378548,0.022770619,0.0044283713,-0.019701183,-0.017375441,0.00044199204,-0.0005298834,0.024230966,-0.012054635,-0.00038494717,0.005611524,-0.0060104155,0.0045940126,0.007957547,-0.0026265988,0.017091485,-0.009201547,-0.007173286,0.00844433,-0.025096359,0.0051788283,-0.010215678,-0.017105008,-0.0036846756,-0.005841394,-0.0025218055,-0.0017645877,0.0065749483,0.0062673287,0.0108782435,-0.013352723,-0.003556219,-0.013609636,-0.0046683825,-0.010398222,-0.0108173955,-0.00317761,-0.011669266,0.009823548,0.00028775964,0.011763918,-0.01914679,-0.0120140705,-0.019038616,0.004999665,-0.007247655,-0.021053357,-0.006409307,0.0036407297,-0.0054830676,0.016077355,-0.0210804,0.028152272,0.00039360955,-0.029504446,-0.008180656,-0.007105677,0.008640395,-0.018430138,0.019309051,-0.006463394,-0.0030778872,-0.013643441,0.018024486,0.0088702645,-0.014955049,0.0045906324,0.016144963,-0.0062673287,-0.023500793,-9.465221e-05,0.002146577,-0.008315873,-0.01302144,0.013156658,0.013487941,0.012987636,-0.0035697406,0.0050638933,0.019417226,-0.0045399256,0.013109332,-0.012088439,-0.008329395,-0.0015837344,0.019106226,0.012352114,-0.020782921,-0.013048484,0.023730662,0.009539591,-0.010066939,0.0006114364,0.016253138,0.0025691316,0.007139481,0.012987636,0.021134486,0.0031066209,0.00504023,-0.0039584907,0.00032114144,-0.013643441,0.010594287,-0.02488001,-0.008187416,0.0060814046,-0.0067980574,-0.009715374,0.01914679,-0.020918138,0.021526618,0.01534718,0.013995006,0.009553113,-0.0077006337,0.00050283986,0.0037421428,0.0011611799,-0.0072949813,0.012622549,-0.0025285662,0.0040497626,0.00844433,-0.0044385125,0.014049093,0.026110489,0.035832625,-0.01410318,0.013995006,0.005026709,0.009492265,0.007261177,0.008538982,-0.0031826806,0.017375441,0.0036677732,0.00100737,-0.010607809,-0.01603679,0.005185589,-0.004286393,-0.014928007,0.009627482,-0.018605921,-0.0016031718,0.020133877,0.00071792013,0.018578878,-0.0108173955,0.012811854,0.020025704,-0.0024609575,-0.0229464,0.0029832348,-0.018768182,0.027584359,0.0140220495,0.021120965,-0.027651967,0.0038469364,0.017699964,-0.0013665414,0.013183701,0.0059968936,-0.007930503,-0.00248124,-0.009641004,0.027624924,-0.0025843435,0.0041511757,-0.009167743,-0.00045044313,0.015211963,-0.0039720125,-0.020106835,-0.0015389436,-0.03402071,-0.017875746,0.008802656,-0.0210804,-0.016604703,0.0020806585,-0.0142519185,-0.011108113,-0.00829559,-0.007193568,0.0015195061,0.011337983,0.0042897733,-0.010127787,-0.0028463274,-0.014211354,0.016807528,0.0048306435,-0.00040290575,-0.0068521444,0.016090875,-0.017605312,0.0021753106,0.0029663327,-0.0034683275,0.0027263218,-0.0028497076,-0.007173286,0.013940919,0.007085394,-8.873645e-06,-0.008234742,-0.00216855,0.034047753,-0.011290657,0.011114874,0.014211354,-0.012757766,0.011966744,-0.009735656,-0.008113047,0.008944634,-0.0005222774,0.022216227,0.00020789682,-0.0051788283,0.0052734804,0.0027094197,-0.0020113594,-0.0031505665,-0.02145901,-0.007835851,-0.017321356,0.005145024,-0.0023764467,0.012156049,-0.011412352,0.010675417,-0.0114732,0.016712876,-0.0067439703,-0.0043742843,0.0050334693,-0.02456901,-0.010776831,-0.009519308,0.010912048,-0.012595505,-0.02882836,0.026705446,-0.016726399,-0.006578329,0.024907054,0.01960653,-0.025393836,-0.01177744,-0.011148678,0.015847486,-0.00048171217,-0.012690158,-0.013981484,-0.002743224,-0.010364417,-0.0040024365,-0.0023933488,-0.010465831,0.0033229687,-0.016631747,0.0010986418,-0.012751006,0.016834572,0.0015262669,-0.020701792,0.01882227,-0.0020941803,0.025218055,0.0058549154,-0.01937666,0.0053512305,-0.007889938,0.013440615,-0.013751615,-0.0042661102,0.0011704761,-0.0019741748,-0.02635388,0.01906566,0.001077514,-0.008180656,0.03477793,-0.043756366,-0.019038616,-0.002146577,-0.008248264,-0.009167743,0.02147253,-0.007619503,-0.019133268,-0.005628426,0.0047630346,-0.000875533,0.004509502,0.021567183,-0.016090875,0.0047528935,-0.016942747,0.008227982,-0.00814009,-0.022581315,0.011513766,-0.03672506,-0.019471312,-0.012433244,0.0055811,0.022351444,-0.0049793827,0.008748569,0.000592844,-0.0060239374,-0.003657632,-0.012020831,-4.5107696e-05,-0.0121357655,0.007741199,0.0036610125,-0.012169571,0.010499635,-0.002449126,-0.012669875,-0.012541418,0.0038705994,0.02471775,0.011337983,-0.012818614,-0.031505667,-0.029801926,-0.021499574,0.014657571,-0.00713272,0.011371788,-0.007078633,0.0014299245,-0.0069636987,-0.005773785,-4.492283e-05,-0.007775003,0.007977829,-0.010945853,-0.012223657,0.015252528,0.0068859486,0.005912383,0.017997442,-0.036157146,0.013028201,0.022270314,-0.004059904,-0.0113177,-0.0056385677,0.017645877,-0.022419052,-0.0030525338,0.009215069,0.02085053,-0.0045771105,0.0054594046,0.020701792,0.012778048,-0.012487331,0.0076397858,0.017077964,-0.012352114,0.020025704,0.01651005,0.010350896,0.008261786,-0.0086742,0.00418498,-0.00035938263,0.008376721,0.01611792,0.0015457044,-0.020755878,0.008255025,-0.0012541418,-0.013596115,-0.004313437,-0.005587861,-0.0024744794,-0.0009794814,0.007944025,-0.005077415,0.0021989737,-0.0016445823,-0.0073963944,-0.0114732,-0.016361311,0.032289926,0.0051416433,0.014806311,-0.010999939,0.0012465358,0.019457791,0.0040159584,-0.000697215,-0.014346572,0.00012085059,-0.008545742,-2.395356e-05,-0.010006092,0.005070654,0.019430747,0.002501523,0.024352662,-0.0023139087,0.004462176,-0.008329395,-0.014197832,-0.015090267,-0.01851127,0.00030128137,-0.0010648374,-0.023203313,0.0010859651,0.0008134175,0.008937873,-0.037860885,0.0111622,0.019457791,-0.0018186746,0.012230418,-0.001813604,-0.011730114,-0.012250701,0.008397004,0.02085053,0.0016750061,-0.0044587953,0.017388964,0.0052667195,-0.009850591,0.0037725668,0.0046548606,-0.008964917,-0.0059495675,-0.030369839,0.0082415035,0.0011231499,0.0030761969,0.003456496,0.022716532,0.024312098,-0.00029874605,0.0076600686,-0.0037353819,0.0069096116,0.009046047,-0.0068859486,-0.004333719,-0.023338532,0.041268364,-0.014170788,0.0005417149,0.007802047,-0.00041114556,0.01123657,0.0047089476,-0.007572177,-0.012352114,-0.016253138,0.012717201,0.01984992,-0.022878792,0.0074504814,-0.021756487,-0.00051340373,0.002533637,-0.004773176,0.013440615,-0.0010352586,-0.037292972,0.0066526984,-0.0022293977,-0.009350287,0.01634779,-0.0048069805,-0.005574339,0.004945578,0.009952004,0.007213851,0.0046413387,0.0060645025,0.0052261543]'::VECTOR(3072)
)
) AS input(input_vector)
WHERE
(1 - (rumi_intent_question.question_vector <=> input.input_vector)) > 0.8
ORDER BY
(1 - (rumi_intent_question.question_vector <=> input.input_vector)) DESC
LIMIT 1;
output
上面的向量查询结果如下
{
"id": "1",
"name": "course_registration_and_enrollment",
"action": "",
"additional_info": "You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process.",
"include_general": 1,
"question": "What is the process for registering for summer classes?",
"similarity": 0.9999990165232773
}
向量相似度计算,代码示例
SQL 模版
--# rumi_intent_classification.intent
SELECT
rumi_intent_classification.id,
rumi_intent_classification.name,
rumi_intent_classification.action,
rumi_intent_classification.additional_info,
rumi_intent_classification.include_general,
rumi_intent_question.question,
(1 - (rumi_intent_question.question_vector <=> input.input_vector)) AS similarity
FROM
rumi_intent_question
LEFT JOIN rumi_intent_classification ON rumi_intent_question.category_id = rumi_intent_classification.id,
LATERAL (
VALUES (
?::VECTOR(3072)
)
) AS input(input_vector)
WHERE
(1 - (rumi_intent_question.question_vector <=> input.input_vector)) > 0.7
ORDER BY
(1 - (rumi_intent_question.question_vector <=> input.input_vector)) DESC
LIMIT 1;
在代码中调用 SQL 模版,进行相似匹配,获取到意图
package com.litongjava.open.chat.services;
import org.junit.Test;
import com.litongjava.db.activerecord.Db;
import com.litongjava.db.activerecord.Record;
import com.litongjava.db.template.SqlTemplates;
import com.litongjava.jfinal.aop.Aop;
import com.litongjava.open.chat.config.DbConfig;
import com.litongjava.openai.constants.OpenAiModels;
import com.litongjava.openai.embedding.EmbeddingResponseVo;
import com.litongjava.openai.utils.EmbeddingVectorUtils;
import com.litongjava.tio.utils.environment.EnvUtils;
import com.litongjava.tio.utils.json.JsonUtils;
public class QuestionSimilarityTest {
@Test
public void test() {
EnvUtils.load();
new DbConfig().config();
String textQuestion = "What is the process for registering for summer classes?";
// 向量
EmbeddingResponseVo vector = Aop.get(VectorService.class).getVector(textQuestion,
OpenAiModels.text_embedding_3_large);
String string = EmbeddingVectorUtils.toString(vector.getData().get(0).getEmbedding());
String sql = SqlTemplates.get("rumi_intent_classification.intent");
// 查询数据库
Record record = Db.findFirst(sql, string);
if (record != null) {
System.out.println(JsonUtils.toJson(record.toMap()));
}
}
}
output
{
"id": "1",
"name": "course_registration_and_enrollment",
"action": "",
"additional_info": "You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process.",
"include_general": 1,
"question": "What is the process for registering for summer classes?",
"similarity": 0.9999990165232773
}
可以看到意图,事件识别到,是 course_registration_and_enrollment
生成推理提示词
根据匹配到意图,生成一个推理提示词 编写一个问题模版 search_init_prompt_v1.txt
Your are the intelligent assistant named Spartan.
#if(category && additional_info)
Your questions mainly come from the category #(category), which means that #(additional_info)
#end
查询数据库,渲染模版
import java.util.HashMap;
import java.util.Map;
import com.jfinal.template.Engine;
import com.jfinal.template.Template;
import com.litongjava.db.activerecord.Db;
import com.litongjava.db.activerecord.Record;
import com.litongjava.db.template.SqlTemplates;
import com.litongjava.jfinal.aop.Aop;
import com.litongjava.open.chat.constants.AiChatEventName;
import com.litongjava.openai.constants.OpenAiModels;
import com.litongjava.openai.embedding.EmbeddingResponseVo;
import com.litongjava.openai.utils.EmbeddingVectorUtils;
import com.litongjava.tio.core.ChannelContext;
import com.litongjava.tio.core.Tio;
import com.litongjava.tio.http.common.sse.SsePacket;
import com.litongjava.tio.utils.json.JsonUtils;
public class SearchInitPromptService {
public String index(String textQuestion, ChannelContext channelContext) {
//向量
EmbeddingResponseVo vector = Aop.get(VectorService.class).getVector(textQuestion,
OpenAiModels.text_embedding_3_large);
String string = EmbeddingVectorUtils.toString(vector.getData().get(0).getEmbedding());
String sql = SqlTemplates.get("rumi_intent_classification.intent");
//查询数据库
Record record = Db.findFirst(sql, string);
//渲染模版
Map<String, String> params = new HashMap<>();
if (record != null) {
if (channelContext != null) {
String json = JsonUtils.toJson(record.toMap());
SsePacket packet = new SsePacket(AiChatEventName.progress, "category:" + json);
Tio.send(channelContext, packet);
}
String category = record.getStr("name").replace('_', ' ');
String additional_info = record.getStr("additional_info");
params.put("category", category);
params.put("additional_info", additional_info);
}
Template template = Engine.use().getTemplate("search_init_prompt_v1.txt");
return template.renderToString(params);
}
}
测试模版渲染
package com.litongjava.open.chat.services;
import org.junit.Test;
import com.litongjava.jfinal.aop.Aop;
import com.litongjava.open.chat.config.DbConfig;
import com.litongjava.open.chat.config.EnjoyEngineConfig;
import com.litongjava.open.chat.config.ExecutorServiceConfig;
import com.litongjava.tio.utils.environment.EnvUtils;
public class SearchInitPromptServiceTest {
@Test
public void test() {
EnvUtils.load();
new DbConfig().config();
new EnjoyEngineConfig().config();
new ExecutorServiceConfig().config();
String textQuestion = "What is the process for registering for summer classes?";
String index = Aop.get(SearchInitPromptService.class).index(textQuestion, null);
System.out.println(index);
}
}
渲染结果
Your are the intelligent assistant named Spartan.
Your questions mainly come from the category course registration and enrollment, which means that You need to provide detailed step-by-step instructions to guide students through course enrollment in the corresponding university. List all available class selection choices and inform students about all possible situations they might encounter during the enrollment process.