When preparing a local knowledge base, we usually deal with question-and-answer pairs and multi-turn dialogues, especially in customer service systems. We want RAG to handle rigorous one-question-one-answer interactions, while also hoping it can chat better and understand dialogue content. In this case, we need to process these data at the same time.
Specific method
We use a CSV table as an example; by using group_id to distinguish different dialogue groups, we can easily integrate single-turn Q&A and multi-turn dialogue.
| group_id | role | content | | 1 | user | Hello, what type of music do you like? | | 1 | assistant | I like listening to pop music. What about you? | | 1 | user | I also like pop music. Recently I've been listening to Jay Chou's songs. | | 1 | assistant | I like his songs very much too. His music always has a strong sense of story. | | 2 | user | Do you like traveling? | | 2 | assistant | I like traveling, especially going to places I've never been to. What about you? | | 2 | user | I also like traveling. Recently I'm planning to go to Japan to see cherry blossoms. | | 2 | assistant | That sounds great! I've always wanted to go to Japan to see cherry blossoms too. | | 3 | user | Have you eaten? | | 3 | assistant | Yes, I have. What about you? | | 4 | user | Hello, the weather is really nice today. | | 4 | assistant | Yes, the weather today is very suitable for outdoor activities. |
Table explanation
The group_id values 1, 2, 3, and 4 represent different groups. Groups 1 and 2 contain multiple rows of data and represent chat dialogues, while groups 3 and 4 contain only one question and one answer and represent Q&A. |