trantuan1701 commited on
Commit
5f1d259
·
1 Parent(s): c39f951

fix prompt

Browse files
Files changed (3) hide show
  1. chatbot/prompts.py +10 -0
  2. data/FAQ.xlsx +0 -0
  3. preprocessing_data.ipynb +113 -0
chatbot/prompts.py CHANGED
@@ -253,5 +253,15 @@ Câu hỏi hiện tại của khách hàng (tập trung trả lời câu hỏi n
253
  {question}
254
 
255
  Hãy dựa vào các thông tin trên để đưa ra câu trả lời chính xác thân thiện nhằm hỗ trợ khách hàng một cách hiệu quả nhất.
 
 
 
 
 
 
 
 
 
 
256
  """
257
  )
 
253
  {question}
254
 
255
  Hãy dựa vào các thông tin trên để đưa ra câu trả lời chính xác thân thiện nhằm hỗ trợ khách hàng một cách hiệu quả nhất.
256
+
257
+
258
+ ### Yêu cầu khi phản hồi:
259
+ - Mỗi sản phẩm gợi ý cần **đính kèm URL** (rất quan trọng).
260
+ - Nếu là **đèn chiếu sáng**, hãy nêu rõ:
261
+ `Giá`, `Công suất`, `Góc chiếu`, `Độ rọi`.
262
+ - Nếu là **bình giữ nhiệt hoặc phích nước**, hãy nêu rõ:
263
+ `Giá`, `Dung tích`, `Thời gian giữ nhiệt`.
264
+ - Ghi đầy đủ các thông tin khác về thông số kỹ thuật, mô tả sản phẩm
265
+
266
  """
267
  )
data/FAQ.xlsx ADDED
Binary file (27.9 kB). View file
 
preprocessing_data.ipynb CHANGED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 2,
6
+ "id": "06013a58",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stderr",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "c:\\Users\\Admin\\anaconda3\\envs\\chatbot_py310\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
14
+ " from .autonotebook import tqdm as notebook_tqdm\n"
15
+ ]
16
+ },
17
+ {
18
+ "name": "stdout",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "WARNING:tensorflow:From c:\\Users\\Admin\\anaconda3\\envs\\chatbot_py310\\lib\\site-packages\\tf_keras\\src\\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.\n",
22
+ "\n"
23
+ ]
24
+ }
25
+ ],
26
+ "source": [
27
+ "from config import EMBEDDING_MODEL\n",
28
+ "from langchain_huggingface import HuggingFaceEmbeddings\n",
29
+ "\n",
30
+ "embedding_model = HuggingFaceEmbeddings(model_name = EMBEDDING_MODEL)"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 5,
36
+ "id": "3a2ac101",
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "sentence_1 = \"Giới thiệu về Rạng Đông\"\n",
41
+ "sentence_2 = \"Cho tôi thông tin về Rạng Đông\"\n",
42
+ "\n",
43
+ "embedding_1 = embedding_model.embed_query(sentence_1)\n",
44
+ "embedding_2 = embedding_model.embed_query(sentence_2)\n"
45
+ ]
46
+ },
47
+ {
48
+ "cell_type": "code",
49
+ "execution_count": 6,
50
+ "id": "50f111d8",
51
+ "metadata": {},
52
+ "outputs": [
53
+ {
54
+ "name": "stdout",
55
+ "output_type": "stream",
56
+ "text": [
57
+ "Độ tương đồng giữa hai câu: 0.6130\n"
58
+ ]
59
+ }
60
+ ],
61
+ "source": [
62
+ "from sklearn.metrics.pairwise import cosine_similarity\n",
63
+ "import numpy as np\n",
64
+ "\n",
65
+ "similarity = cosine_similarity(\n",
66
+ " [embedding_1],\n",
67
+ " [embedding_2]\n",
68
+ ")[0][0]\n",
69
+ "\n",
70
+ "print(f\"Độ tương đồng giữa hai câu: {similarity:.4f}\")\n"
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "code",
75
+ "execution_count": 8,
76
+ "id": "759170ce",
77
+ "metadata": {},
78
+ "outputs": [],
79
+ "source": [
80
+ "embedding_model2 = HuggingFaceEmbeddings(model_name =\"keepitreal/vietnamese-sbert\")"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": null,
86
+ "id": "0907798e",
87
+ "metadata": {},
88
+ "outputs": [],
89
+ "source": []
90
+ }
91
+ ],
92
+ "metadata": {
93
+ "kernelspec": {
94
+ "display_name": "chatbot_py310",
95
+ "language": "python",
96
+ "name": "python3"
97
+ },
98
+ "language_info": {
99
+ "codemirror_mode": {
100
+ "name": "ipython",
101
+ "version": 3
102
+ },
103
+ "file_extension": ".py",
104
+ "mimetype": "text/x-python",
105
+ "name": "python",
106
+ "nbconvert_exporter": "python",
107
+ "pygments_lexer": "ipython3",
108
+ "version": "3.10.16"
109
+ }
110
+ },
111
+ "nbformat": 4,
112
+ "nbformat_minor": 5
113
+ }