iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🥈

🚀 Winning a Solo Silver Medal at SIGNATE RAG-1 Grand Prix: Journey to 20th Place and Key Learnings 🚀

に公開

Introduction

I participated solo in SIGNATE's "RAG-1 Grand Prix," held from September to October 2024, and achieved 20th place out of 509 participants, earning a silver medal. In this article, I will share the overview of the competition, my approach, the challenges I faced and their solutions, and the lessons I learned.

What is RAG-1 Grand Prix?

Competition Overview

The "RAG-1 Grand Prix" is a competition themed around next-generation Retrieval-Augmented Generation (RAG) technology, aiming to solve challenges in generative AI technology. Hosted by SIGNATE Inc., it was held from September 12 to October 10, 2024. Participants generated answers to given questions based on provided novel data and competed on the accuracy of those answers.

https://signate.jp/competitions/1407

Competition Background

  • Generative AI and LLMs are evolving rapidly, and their potential applications are expanding daily, but the serious challenge of "hallucination" (generation of false information) acts as a barrier to practical use.
  • Especially in business applications, the generation of false information can be a fatal issue, which is why many companies are cautious about adopting LLMs.
  • RAG (a mechanism to supplement LLMs with external information) is attracting attention as a powerful technology to solve this problem, but it is still in the developmental stage and standard implementation methods have not yet been established.

Competition Purpose

Through this competition, the goal is to compete for the best way to build a RAG system based on a given dataset and to gain practical implementation insights.

Specifically, exploring optimal methods in the following elements:

  1. Data preprocessing and formatting methods
  2. Selection of efficient search algorithms
  3. Effective integration methods with LLMs

Sharing these insights aims to promote the practical application of RAG technology and contribute to improving reliability in the business use of LLMs, which is the primary goal of this competition.

Competition Task

Quoted from the official page:

In this competition, you will build a RAG system using public domain novel data. Based on the provided novel data, you will generate answers to questions (query.csv) and compete on the accuracy of those answers. Please submit the generated answers according to the specified format (refer to sample_submission.csv in the provided data).

Evaluation Method

Quoted from the official page:

  • Evaluation is based on measuring the quality of the answer to each question.
  • Answers are classified by an LLM (gpt-4o) into "Perfect," "Acceptable," "Missing," or "Incorrect" based on the following criteria, and points are awarded.
  • The score is the average value obtained by dividing the total points by the number of questions.
  • The question data includes questions with incorrect premises. In such cases, answering "Question Error" will result in a "Perfect" evaluation.
  • Scores range from -1 (all Incorrect) to 1 (all Perfect).
  • The score is based on the result of a single LLM evaluation performed after the answer is submitted.

The evaluation method above is based on a benchmark for performance evaluation of the latest RAG (Retrieval-Augmented Generation) systems called "CRAG (Comprehensive RAG Benchmark)," which was published in the following paper.

Reference Paper:
https://arxiv.org/abs/2406.04744

As a slight tangent, let me briefly explain this CRAG. In this RAG-1 Grand Prix, an automated evaluation method derived from CRAG (Comprehensive RAG Benchmark) was adopted. This evaluation method is designed to objectively assess the accuracy and reliability of generated answers.

Evaluation Categories and Scoring

In the CRAG evaluation method, each answer is classified into the following four categories, with corresponding scores assigned to each:

Category Score Evaluation Criteria
Perfect 1 Answers that accurately address the question and contain no hallucinations.
Acceptable 0.5 Answers that provide a useful response to the question but contain minor errors that do not compromise the usefulness of the answer.
Missing 0 Answers that do not provide a specific response to the question, such as "I don't know" or "Not found."
Incorrect -1 Answers that are wrong or irrelevant to the question.

This scoring method allows for strict evaluation, especially against the phenomenon known as "hallucination," where the model generates information not based on facts.

Calculating the Truthfulness Score

Based on the evaluation results of each answer, a Truthfulness Score is calculated to show the truthfulness of the entire system. The calculation formula is as follows:

\text{Truthfulness} = \frac{\text{Number of Perfect Answers} + 0.5 \times \text{Number of Acceptable Answers} - \text{Number of Incorrect Answers}}{\text{Total Number of Questions}}

With this calculation, a system that provides many accurate answers will receive a high score, while a system that generates false information will receive a low score.

Automated Evaluation Process

In the RAG-1 Grand Prix, the following process is adopted as the automated evaluation method:

  1. Exact Match Check: If the generated answer matches the ground truth data exactly, it is automatically evaluated as "Perfect."
  2. LLM-based Evaluation: If they do not match, an LLM (Large Language Model) is used to classify the answer as "Acceptable," "Incorrect," or "Missing."

This automated evaluation method enables rapid and objective evaluation, allowing for the efficient assessment of a large number of answers.

In other words...

The CRAG-derived automated evaluation method adopted in the RAG-1 Grand Prix is an important means of increasing the accuracy and reliability of generated answers. In particular, it contributes to suppressing hallucinations and reducing misinformation, greatly improving the quality of RAG systems. A deep understanding of the evaluation method is a key point in the competition. This is because the evaluation method considers not only improving the correct answer rate but also penalties for wrong answers or hallucinations, necessitating a high-precision answering strategy. As a participant, you can achieve a high score by focusing on appropriate information retrieval and reliable answer generation.

My Solution

Now, after a long introduction, I would like to describe my Solution below.
The code I built this time is published in the following GitHub repository. Since I started working on the competition about a week before the final deadline, the code itself is quite rough, so please bear with me on that point.

https://github.com/naoki1213mj/FY2024-rag1-solution.git

RAG System Architecture (Overall View)

This RAG system was designed around the process shown above using Google's "gemini-1.5-pro-002". In addition to a conventional simple RAG approach, this system adopted a multi-stage reasoning approach, aiming for high-precision answers to the questions. Among the top prize winners, it might be considered a bit unusual, as I did not adopt a mainstream RAG approach. The reasons were primarily the short amount of time I had to work on it, and the fact that a RAG system using simple vector search that I initially implemented didn't improve beyond a score of 0.3. Therefore, I decided to tackle this task using the brute force of a long-context LLM.

Now, I will briefly explain the flow of processing in this Solution step by step.

A: Data Preprocessing

  • Unifying Encoding: The provided novel files were in Shift_JIS format, but I converted them all to UTF-8 to maintain compatibility between platforms.
  • Organizing File Names: To improve visibility, I used the title mentioned in the first line of the novel as the file name.
  • Removing Unnecessary Information: I performed data cleansing, such as removing unnecessary elements like symbol explanations and base text information, replacing full-width spaces with half-width spaces, and deleting extra whitespace and empty lines.

On the other hand...

  • Processing I tried but didn't work: When I tried to convert Kanji numerals to Arabic numerals (e.g., 一→1, 二→2, ..., 十→10), it caused issues. For example, if an expression like "二○二" (representing the number "202") existed in a novel file, this process would convert it to "2○2," which resulted in passing incorrect information to the LLM as input and caused wrong answers. Therefore, I eventually excluded this process.

B: Inferring the Novel File Associated with a Question

To infer which novel a question relates to, I used gemini-1.5-pro-002 and performed a search leveraging its long context. Specifically, the points of ingenuity are as follows:

  • Using all novel files in the context: Since the input token limit is as long as 2 million tokens, I performed inference by including all novel files at once.
  • Prompt Engineering: Using OpenAI's automatic prompt generation feature, I adapted the "prompt that gives Claude the reasoning power of o1," which has been a topic of interest on international social media.

https://medium.com/@harishhacker3010/can-we-make-any-smaller-opensource-ai-models-smarter-than-human-1ea507e644a0

The following is the prompt I actually used to infer the novel file associated with a question.

Prompt used
## Role

You are an expert at analyzing the content of classical Japanese novels and inferring which novel a question was taken from. Please use metacognition to make inferences according to the following processes and instructions.

## Response Process

1. Enclose all thinking processes in <thinking> tags and explore multiple angles and approaches.
2. Break down the solution into clear steps and describe them within <step> tags. Start with 20 steps and request additional steps for complex problems.
3. Use a <count> tag after each step to indicate the number of remaining steps. Stop when it reaches 0.
4. Continuously adjust your reasoning based on intermediate results or reflections, adapting your strategy as you progress.
5. Use <reflection> tags to periodically evaluate progress. Be critical and honest in assessing the reasoning process.
6. After each reflection, assign a quality score between 0.0 and 1.0 using <reward> tags. Use this score to guide your approach:
- 0.8 or higher: Continue current approach
- 0.5-0.7: Consider minor adjustments
- Below 0.5: Seriously consider trying a different approach
7. If uncertain or if the reward score is low, backtrack and try another approach, explaining the decision within <thinking> tags.
8. Explore multiple solutions separately where possible, and compare each approach in the reflection.
9. Use your thoughts as a notepad, writing out all calculations and reasoning explicitly.
10. Provide the final answer (novel file name) within <answer> tags, providing a clear and concise summary.
11. Conduct a final reflection on the overall solution, discussing effectiveness, challenges, and solutions, and assign a final reward score.

## Instructions

1. **Review Novel Overview**: Review the titles and contents of the novels provided below. Each novel is provided in the following format:
'File Name': 'Novel Content'
2. **Analyze Question**: Analyze the context and keywords of the question.
3. **Evaluate Relevance**: Consider which novel's content the information in the question is most relevant to.
4. **Inference**: Clearly state which novel the question is believed to have been taken from.

## Notes

- Based on the format of the provided novel content, carefully check which novel file contains sentences or keywords related to the question, and ensure you do not hallucinate.

## Novel Content

Each novel is listed in the format "'File Name': 'Novel Content'". Be careful not to mismatch file names and content.
{Text content of all novels}

## Question
{query}

Please begin the response process.
The final answer should be output as the novel file name only, within **<answer>novel_filename.txt</answer> tags**, as follows.

C: Rewriting the Question

To increase search efficiency and answer accuracy, I adopted a technique called "Question Rewriting," inspired by the following paper:

https://arxiv.org/abs/2305.14283

I focused on the following points:

  • Question Optimization: Changed ambiguous expressions into specific phrasing and placed words that serve as search keywords at the beginning.
  • Improving Rewrite Accuracy: By performing the question rewriting after the relevant novel file was identified, I achieved higher accuracy.

On the other hand...

  • Processing I tried but didn't work: When using all novel files as context, the score actually decreased compared to cases where no rewriting was performed.

The following is the prompt I actually used for question rewriting.

Prompt used
You are an expert in advanced natural language processing and information retrieval. Please rewrite the following question about a novel to increase search efficiency and answer accuracy in a document retrieval system.

## Original Question
{original_query}

## Target Novel File
{Content of the novel associated with each question}

## Instructions

1. Question Analysis:
- Identify the main elements of the question (characters, locations, events, concepts, etc.).
- Determine the question type (fact-checking, numerical, comparison, reason, method, etc.).
2. Context Consideration:
- Referencing the target novel filename, consider the characteristics and main themes of that novel.
- If there are terms or expressions specific to the novel, utilize them.
3. Question Optimization:
- Eliminate ambiguity and rewrite into specific and clear expressions.
- Place important words or expressions that serve as search keywords at the beginning of the question.
- Do not change the novel title or proper nouns; use them as they are.
- Retain numerical values or units if included.
4. Improving Search Efficiency:
- Add synonyms or related expressions to broaden the search scope.
- If necessary, split the question into multiple parts.
- Change expressions like "What is...?" or "Please list..." into more direct forms.
5. Specifying Answer Format:
- Clarify the expected answer format (list, numerical value, explanation, etc.).
6. Verification:
- Confirm that the rewritten question retains the original intent.
- Confirm that the expression is easy for the search system to understand and also readable for humans.

## Output Format
Output only the rewritten question. No explanation or justification is needed.

## Rewritten Question

D: Answer Generation

For answer generation, I used gemini-1.5-pro-002 and constructed the prompt using both the rewritten question and the original question. (As a small regret, if I had a little more time, I should have also tried models said to be higher performance than gemini-1.5-pro-002, such as GPT-4o or o1-preview.)

The points of ingenuity are as follows:

  • Using both the original and rewritten questions: I used not only the rewritten question from process C but also the original question within the prompt. This is because the paper I mentioned earlier stated that searching only with the rewritten question can lead to losing the original intent and decreasing accuracy.

Reprinted:
https://arxiv.org/abs/2305.14283

  • Many-shot Prompting: Leveraging Gemini's long context, I created Many-shot examples containing over 50 pairs of question-answer-evidence. I created these examples manually and by having Gemini generate them. Additionally, I was careful to create as diverse examples as possible to avoid including any examples that could result in "cheating."

https://arxiv.org/abs/2404.11018

  • Prompt Engineering: Based on OpenAI's automatic generation feature, I analyzed the intent of the questions and the information needed for the answers, deriving answers through a multi-layered strategy. For this answer generation prompt, I also applied the "prompt that gives Claude the reasoning power of o1" that was trending on international social media.

Reprinted:
https://medium.com/@harishhacker3010/can-we-make-any-smaller-opensource-ai-models-smarter-than-human-1ea507e644a0

The following are the prompt and Many-shot examples actually used for answer generation.

Prompt used
## Role and Purpose
You are a literature expert who precisely analyzes modern Japanese novels and accurately answers questions. Use only the provided **## Novel Content** and answer the questions using metacognition. Use a bird's eye view (overall picture), a fish's eye view (details), and an insect's eye view (minute relationships) to explore the information needed to answer the question in detail.

## Response Process
1. Question Analysis: Perform the following within 0cthinking0e tags
   - Comparative analysis of the original **## Question** and the **## Rewritten Question**
   - Identification and prioritization of elements required for the answer
   - Clarification and organization of requirements strictly necessary for the answer as stated in the question
   - Accurate understanding of the intent/premise of the question and potential complexities
   - Multi-angled strategy planning to identify relevant parts within the novel
   - Exploration and evaluation of multiple interpretative possibilities
0c/thinking0e

2. Solution Construction: Execute the following steps, keeping in mind the **## Contextual Understanding and Information Integration**, **## Answer Construction Method**, and **## Strict Observances** below, and adding steps as necessary. Enclose each step in 0cstep0e tags and indicate the number of remaining steps with 0ccount0e tags.
   0cstep0e1. Comprehensive identification of relevant parts (utilize keywords, synonyms, and context. List occurrences by checking the entire text multiple times in detail)0c/step0e
   0cstep0e2. Extraction and multi-layered organization of relevant information (ranking by importance, chronology, and causality)0c/step0e
   0cstep0e3. Logical assembly of information (resolving contradictions in a form that directly answers the question)0c/step0e
   0cstep0e4. Selection of multiple supporting citations (prioritize the most relevant parts)0c/step0e
   0cstep0e5. Concise and comprehensive summary of the answer (within 50 characters, capturing the core essence)0c/step0e

3. Reflection and Evaluation: After each step, evaluate progress with 0creflection0e tags and assign a quality score from 0.0 to 1.0 with 0creward0e tags, following these guidelines:
   - 0.9 or higher: Continue current approach
   - 0.7-0.8: Consider minor adjustments
   - 0.5-0.6: Consider a major overhaul
   - Below 0.5: Adopt a completely new approach

4. Approach Adjustment:
   - If the score is low, backtrack and try a different approach, explaining the reason in 0cthinking0e tags
   - Explore multiple solutions in parallel and select the optimal one at the end
   - Explicitly describe all reasoning and adjust continuously based on intermediate results and reflections
   - If uncertainty is high, formulate and verify multiple hypotheses

## Contextual Understanding and Information Integration
1. Read the entire text multiple times and consider not only surface information but also potential meanings and symbolism.
2. Map chronological sequences, spatial changes, and transitions in character relationships in detail, analyzing relevance to the question from multiple angles.
3. Distinguish between explicit and implicit information, providing detailed explanations for the reasoning process in the latter case.
4. For questions regarding numerical values or time, integrate scattered information throughout the text, performing interpolation or extrapolation as necessary.
5. Deeply analyze psychological changes and motivations of characters to infer the reasons behind their actions.
6. Consider the theme of the work, historical background, and the author's intent to interpret individual events within a larger context.
7. If there is contradictory information, organize it and present the most plausible interpretation.
8. Even if information is not directly related to the question, explore its potential indirect relevance.

## Answer Construction Method
1. Exhaustively list relevant information and analyze their interrelationships multidimensionally.
2. Objectively evaluate information reliability, importance, and relevance to select the best information.
3. If multiple interpretations are possible, evaluate the validity of each and select the optimal one or present multiple possibilities.
4. When performing reasoning or calculations, clearly show each step and explain the information used and the logical flow in detail.
5. If there are uncertain elements, state the degree and impact of that uncertainty, and explain under what assumptions the answer was derived.
6. For questions regarding elapsed time or age, perform calculations by integrating multiple pieces of information in the text, stating the process and assumptions clearly.
7. For answers based on inference, verify the validity of the inference from multiple perspectives and back it up with information in the text as much as possible.
8. Explicitly state the confidence level of the answer, and provide alternative interpretations or possibilities if confidence is low.

## Strict Observances
Based on the **## Answer and Evidence Examples** below, follow each of these points to provide your answer:

1. Source and Accuracy:
   - Use only the novel's content, completely excluding external knowledge or inappropriate speculation.
   - Reconsider answers or interpretations that are impossible compared to common sense. However, note that novels are fiction and may differ from common sense.
   - Carefully exclude information not directly related to the question while considering indirect relevance.
   - Ensure maximum accuracy for numerical values and always include appropriate units requested by the question.
   - Accurately interpret Kanji numerals, Arabic numerals, and numeric expressions including "〇" as follows:
     - Kanji to Arabic conversion: Fifteen seconds = 15 seconds, Twenty-five seconds = 25 seconds
     - Expressions including "〇": Twenty(䄠) years old = 20 years old, Thirty(䀰) years = 30 years, Two hundred and two(䈂) years old = 202 years old, Three hundred and three(䌃) Kan = 303 Kan
   - Approximate expressions (e.g., twenty or thirty years) should be interpreted as a range, and that range should be clearly stated (e.g., 20–30 years).
   - When performing calculations regarding age or passage of time, extract appropriate information from the context and reason logically. Explicitly state all assumptions and calculation processes.

2. Judgment of Answers:
   - Answer "I don't know" ((分ぃもすん)) only if no clues or relevant information for the answer can be found in the source, and reasonable inference is also impossible.
   - If the question itself is incorrect, answer "Question Error" ((質問誤り)) and explain the reason concisely and clearly.
   - Thoroughly consider all possibilities before answering "I don't know" or "Question Error."

3. Handling Questions:
   - Thoroughly cross-reference the question content with the novel content, aiming for the most complete and accurate answer possible.
   - For ambiguous questions, show all possible interpretations and then answer based on the interpretation deemed most appropriate.
   - For questions asking for the number of occurrences, be extremely careful not to miss any and provide an accurate count.
   - Understand every word of the novel accurately, and analyze the relevance to the question from multiple angles, considering context and implications.

4. Answer Format:
   - Strictly follow the format, answering style, and thinking approach provided in the answer and evidence examples.
   - Prioritize conciseness and accuracy in the answer, adding supplementary explanations as needed.

## Criteria
- "I don't know" ((分ぃもすん)): When no relevant information or clues for the question or answer are found in the novel, and reasonable inference is impossible.
- "Question Error" ((質問誤り)): When the question clearly contradicts the novel content, the premise of the question is wrong, the question itself has logical errors, or a direct answer to the question cannot be provided.

## Streamlining Information Extraction
- Systematic extraction and analysis of keywords, synonyms, and related concepts
- Multi-layered understanding of context (surface meaning, implication, symbolic meaning)
- Multidimensional hierarchy and processing based on information importance, reliability, and relevance

## Output Format
- Answer: 0canswer0e[Concise and accurate answer within 50 characters]0c/answer0e
- Evidence: 0cevidence0e[Direct citation from the novel and detailed explanation of the reasoning process within 100 characters]0c/evidence0e

## Final Evaluation
Perform a final reflection on the overall solution from the following perspectives:
1. Accuracy and completeness of the answer
2. Logic and transparency of the reasoning process
3. Depth and multi-facetedness of contextual understanding
4. Consideration of unexpected interpretations or possibilities
5. Conciseness and clarity of the answer
Finally, evaluate these perspectives comprehensively and assign a final reward score.

## Answer and Evidence Examples
{many_shot_examples}

## Novel Content
{textwrap.indent(novel_content, '    ')}

## Original Question
{query}

## Rewritten Question
{rewrite_query}

## Output
Strictly follow the above items, especially the **Strict Observances**, and begin the **Response Process** using metacognition, critical thinking, a bird's eye view (overall picture), a fish's eye view (details), and an insect's eye view (minute relationships) to the maximum extent.
Many-shot examples
### Fact-checking Questions
Question: In the novel "Nonki na Kanja" (The Easygoing Patient), which part of the protagonist Yoshida's body is primarily affected?
0canswer0eLungs0c/answer0e
0cevidence0e"Yoshida has bad lungs."0c/evidence0e

Question: In "Yukiguni" (Snow Country), what age did Komako tell Shimamura she was?
0canswer0e20 years old0c/answer0e
0cevidence0e"I've turned twenty," Komako told Shimamura.0c/evidence0e

Question: In "Kokoro," where did K commit suicide?
0canswer0eA room in the lodgings0c/answer0e
0cevidence0e"K had quietly hanged himself in a room of his own lodgings."0c/evidence0e

Question: What was the age of the protagonist in "Botchan" when he took up his post?
0canswer0e23 years old0c/answer0e
0cevidence0eThere is a description: "In the spring of my twenty-third year, three days before my parents died, I took up my post in Makiyama." Here, "twenty-three" means 23 years old.0c/evidence0e

Question: Roughly when did "Sensei" in "Kokoro" stay at the lodgings?
0canswer0eAround 20 years old0c/answer0e
0cevidence0eThere is a description: "I was already past twenty at that time," which suggests he was over 20 years old.0c/evidence0e

Question: In "Michizo no Sobo" (Michizo's Grandmother), how old is the grandmother described to be?
0canswer0e70 years old0c/answer0e
0cevidence0eThe work contains the description: "It is said that grandmother is Koki (70) this year." Here, "70" means 70 years old.0c/evidence0e

### List Creation Questions
Question: In the novel "Nonki na Kanja," list everything that Yoshida was advised to drink.
0canswer0eCharred human brains, a hangman's rope, charred mouse pups0c/answer0e
0cevidence0e"Charred human brains," "a hang|man's rope," "things made by catching mouse pups, putting them in, and charring them."0c/evidence0e

Question: List all the places specifically mentioned as the hometowns of the laborers appearing in "Kanikousen" (The Crab Cannery Ship). (Separate with commas)
0canswer0eAomori, Iwate, Akita, Yamagata, Niigata, Toyama0c/answer0e
0cevidence0e"The laborers on the crab cannery ship were from poor farming villages in Tohoku and Hokuriku, such as Aomori, Iwate, Akita, Yamagata, Niigata, and Toyama."0c/evidence0e

Question: In "Chijin no Ai" (Naomi), list all the lessons Naomi was taking. (Separate with commas)
0canswer0eEnglish, Dance, Piano0c/answer0e
0cevidence0e"Naomi was learning English, dance, and piano. I spent money unsparingly on her education."0c/evidence0e

### Numerical Calculation Questions
Question: In the novel "Nonki na Kanja," how many people approached Yoshida after realizing he was a tuberculosis patient?
0canswer0e4 people0c/answer0e
0cevidence0eIt is described that four people approached Yoshida: a vegetable-selling woman, a lacquerer from Yamato, a hospital attendant, and a Tenrikyo woman.0c/evidence0e

Question: According to the statistics in the novel "Nonki na Kanja," what is the percentage of upper-class people among those who died of pulmonary tuberculosis?
0canswer0eLess than 1%0c/answer0e
0cevidence0eThere is a description: "Upper-class people are not even one of them yet." Since it is less than 1 out of 100 people, it is less than 1%.0c/evidence0e

Question: In "Botchan," what is the difference between the monthly salary the protagonist received and his lodging expenses?
0canswer0e25 yen0c/answer0e
0cevidence0eThere are descriptions of "monthly salary 40 yen" and "lodging expenses 15 yen." 40 yen - 15 yen = 25 yen.0c/evidence0e

Question: In "Botchan," how many kilometers is the protagonist thought to have traveled from taking the train until arriving at the lodgings?
0canswer0eAbout 12 kilometers0c/answer0e
0cevidence0eThere is a description: "Arrived at the station in about 30 minutes after getting on the train, and from there ran for about 15 minutes by rickshaw." Assuming the train's speed is 40 km/h and the rickshaw's speed is 8 km/h, (40 km/h * 0.5 h) + (8 km/h * 0.25 h) ≈ 22 km.0c/evidence0e

Question: In "Kusamakura" (The Three-Cornered World), how many meters can the protagonist be inferred to have walked from arriving at the hot spring inn until meeting Nami?
0canswer0eAbout 800 meters0c/answer0e
0cevidence0eThere is a description: "Walked for about 10 minutes after leaving the inn, then climbed the mountain path for another 5 minutes." Assuming a walking speed of 80 m/min on flat ground and 60 m/min on mountain paths, (80 m/min * 10 min) + (60 m/min * 5 min) = 800 + 300 = 1100 meters.0c/evidence0e

Question: In "Ginga Tetsudou no Yoru" (Night on the Galactic Railroad), how many light-years is the train Giovanni and Campanella rode estimated to have traveled from departure to the first station?
0canswer0eAbout 100 light-years0c/answer0e
0cevidence0eThere is a description: "Soon the train began to move 10 times its initial speed, and arrived at the first star about 10 minutes later." Assuming movement in outer space and an initial speed of 0.1 times the speed of light, it can be estimated as (0.1c * 10 * 10 min) ≈ 100 light-years.0c/evidence0e

Question: In the novel "Saigetsu" (The Years), roughly how many years are thought to have passed from when the protagonist's older brother first fell seriously ill until he passed away?
0canswer0eRoughly 17 years0c/answer0e
0cevidence0eThere is a description: "My brother had his first seizure at twenty-three and lived a long life of fighting the illness thereafter. He finally passed away at forty." 40 - 23 = 17 years.0c/evidence0e

Question: In the work "Seishun no Wadachi" (Tracks of Youth), how much time has passed since the protagonist met his first love until they met again?
0canswer0eAbout 15 years0c/answer0e
0cevidence0eThere is a description: "I accidentally met her again now that I am thirty, the girl I met when I was a high school sophomore." Assuming a high school sophomore is fifteen, 30 - 15 = 15 years.0c/evidence0e

Question: In the novel "Toki no Nagare" (The Flow of Time), roughly how many years passed from when the protagonist left his hometown until he returned again?
0canswer0eAbout 22 years0c/answer0e
0cevidence0eThere is a description: "Left for Tokyo in the spring of eighteen, and stepped on the soil of my hometown for the first time at the age of forty." 40 - 18 = 22 years, but answered as "About 22 years" using the expression "roughly."0c/evidence0e

### Questions Counting Occurrences or Appearances
Question: In "Ningen Shikkaku" (No Longer Human), how many times does the sentence "I have lived a life of much shame" appear?
0canswer0e2 times0c/answer0e
0cevidence0eThe sentence "I have lived a life of much shame" appears twice, at the beginning and the end of the novel.0c/evidence0e

Question: In "Sangetsuki" (The Moon over the Mountain), how many times does the word "tiger" appear in the work?
0canswer0e17 times0c/answer0e
0cevidence0eThroughout the entire novel "Sangetsuki," the word "tiger" is used 17 times.0c/evidence0e

Question: In "Hashire Melos" (Run, Melos!), how many times does the word "friendship" appear in the work?
0canswer0e5 times0c/answer0e
0cevidence0eThroughout the text of "Hashire Melos," the word "friendship" is used 5 times.0c/evidence0e

### Questions Asking for Interpretation or Relationships
Question: In the novel "Nonki na Kanja," why did the hangman's rope sell for a high price?
0canswer0eBecause lung disease patients believed in superstitions seeking salvation0c/answer
0cevidence0eIt can be understood that it was believed that "a rope used for hanging becomes medicine for illness," and it was traded for a high amount.0c/evidence0e

Question: How does the relationship between the servant and the old woman in "Rashomon" change?
0canswer0eChanges from victim and perpetrator to accomplices0c/answer0e
0cevidence0e"After the servant stole the clothes from the old woman, he thought, 'That woman did exactly what I was about to do,' and felt a sense of empathy."0c/evidence0e

Question: In "Maihime" (The Dancing Girl), how does the relationship between the protagonist Toyotaro and Elis change?
0canswer0eFrom protector and protected to lovers, and finally separation0c/answer0e
0cevidence0eThe progression "Initially helped her out of pity, but eventually fell in love, and finally abandoned her and returned to Japan" is depicted in the work.0c/evidence0e

### Questions Requiring Inference
Question: In "Kokoro," what is considered the primary reason "Sensei" decided to commit suicide?
0canswer0eThe death of Emperor Meiji and the inability to adapt to the changing era accompanying it0c/answer0e
0cevidence0eFrom Sensei's words, "Now that the spirit of Meiji is dead, I too must die," it is clear that the death of Emperor Meiji was the trigger for his suicide.0c/evidence0e

Question: List all the physical characteristics of the protagonist appearing in "Yuki-onna" (The Snow Woman). (Separate with commas)
0canswer0eFair-skinned, slender face, almond-shaped eyes, black hair, slender build0c/answer0e
0cevidence0eThere is a description: "Owner of a fair-skinned slender face, almond-shaped eyes, jet-black hair, and a slender build."0c/evidence0e

Question: List all types of trees appearing in "Gekkou no Mori" (Moonlight Forest). (Separate with commas)
0canswer0eCedar, Pine, Maple, Cherry, Willow0c/answer0e
0cevidence0eThe five types of trees specifically mentioned in the work are "giant cedar trees, ancient pines, maples turning red, cherries that bloom in spring, and a willow standing by the pond."0c/evidence0e

Question: In "Toki no Sunadokei" (Hourglass of Time), list all the eras in which the protagonist traveled through time.
0canswer0e1945, 2020, 21000c/answer0e
0cevidence0eIn the novel, it is clearly described that the protagonist time-traveled to "just after the end of the war in 1945, the present day in 2020, and the future in 2100."0c/evidence0e

### Questions Asking for Chronology or Order
Question: In "Sangetsuki," how much time has passed since Li Zheng became a tiger until he met Yuan Can?
0canswer0eAbout 1 year0c/answer0e
0cevidence0eFrom the description, "Thereafter, I lived in the mountains near human habitation for nearly a year," it is clear that he met Yuan Can about a year after Li Zheng became a tiger.0c/evidence0e

Question: In the novel "Densetsu" (Legend), roughly how many days are thought to have passed from the time the protagonist moves from Chiba to Tokyo until the actual inventory is completed?
0canswer0eAbout 2 months0c/answer0e
0cevidence0eThere is a description: "It took about two months while moving from Chiba to the house in Tokyo."0c/evidence0e

### Questions Answering "I don't know"
Question: What was the reason the pet dog wanted to go for a walk?
0canswer0eI don't know0c/answer0e
0cevidence0eIn the novel "Nonki na Kanja," the reason the pet dog wanted to go for a walk is about to be mentioned, but there is no description thereafter.0c/evidence0e

Question: What is the real name of "Yama-arashi" appearing in "Botchan"?
0canswer0eI don't know0c/answer0e
0cevidence0eIn the novel "Botchan," the real name of "Yama-arashi" is not revealed. He is called only by his nickname.0c/evidence0e

Question: Specifically how many centimeters is the nose of the protagonist Naiku written to be in "Hana" (The Nose)?
0canswer0eI don't know0c/answer0e
0cevidence0eIn Akutagawa Ryunosuke's "Hana," it is stated that Naiku's nose is very long, but the specific length is not explicitly mentioned in centimeters.0c/evidence0e

Question: In "Kokoro," what is the exact date "Sensei's" parents passed away?
0canswer0eI don't know0c/answer0e
0cevidence0eIn the novel "Kokoro," it is mentioned that Sensei's parents passed away, but the exact date is not explicitly stated.0c/evidence0e

### Questions Answering "Question Error"
Question: In the novel "Nonki na Kanja," what was the trigger for Yoshida starting to attend the Tenrikyo church?
0canswer0eQuestion Error0c/answer0e
0cevidence0eThere is no description that Yoshida started attending the Tenrikyo church. Yoshida was approached by a Tenrikyo woman but declined to go to the church.0c/evidence0e

Question: What is the name of the secret sword technique used by the protagonist in "Gen'ei no Kenshi" (The Phantom Swordsman)?
0canswer0eQuestion Error0c/answer0e
0cevidence0eIn the work, the protagonist's sword skills are expressed as "godlike" or "superhuman," but no specific secret sword name is stated. It becomes clear in the latter half that the protagonist's skills are due to advanced swordsmanship and reflexes, not an actual "secret sword technique."0c/evidence0e

Question: In "Kiri no Tantei" (Detective in the Mist), what is the name of the superpower the detective used when chasing the culprit?
0canswer0eQuestion Error0c/answer0e
0cevidence0eIn the novel, the detective's abilities are described as "superhuman" or "like a sixth sense," but no specific superpower name or type is explicitly stated. In reality, it becomes clear in the climax that the detective's excellent observation and reasoning skills just "look like a superpower," and he is using realistic detective techniques.0c/evidence0e

Question: In "Kage no Ninja" (Shadow Ninja), what is the name of the forbidden ninjutsu the protagonist used to defeat the enemy?
0canswer0eQuestion Error0c/answer0e
0cevidence0eIn the work, the protagonist's technique is expressed as "like a forbidden technique" or "extraordinary," but no specific ninjutsu name is mentioned. In reality, it is revealed at the end that the protagonist uses advanced physical techniques and tools skillfully, and the "forbidden ninjutsu" does not exist.0c/evidence0e

Question: In "Hoshiboshi no Yogen-sha" (Prophet of the Stars), tell me the specific name of the astrology method the protagonist used to predict the future.
0canswer0eQuestion Error0c/answer0e
0cevidence0eIn the novel, the protagonist's prophetic ability is described as "the guidance of the stars" or "revelations from the universe," but no specific astrology method name is explicitly stated. As the story unfolds, it becomes clear that the protagonist's "prediction" is actually inference based on meticulous information gathering and analysis.0c/evidence0e

Question: In "Kikai-jikake no Shinzou" (The Clockwork Heart), what is the name of the alchemy the protagonist used to extend his own lifespan?
0canswer0eQuestion Error0c/answer0e
0cevidence0eIn the work, the protagonist's longevity is expressed as "a miracle by alchemy" or "the art of immortality," but no specific alchemy name is shown. At the end, it becomes clear that the protagonist's longevity is actually the result of advanced medical technology and health management, and alchemy was a metaphorical expression.0c/evidence0e

Question: In "Toki no Meikyuu" (The Labyrinth of Time), what is the model number of the time machine the protagonist used to resolve the time paradox?
0canswer0eQuestion Error0c/answer0e
0cevidence0eIn the novel "Toki no Meikyuu," the protagonist is depicted as having the ability to manipulate time, but no specific time machine appears. As the story unfolds, it becomes clear that the protagonist's "time manipulation" is actually an outstanding ability to investigate past events in detail and predict the future. The time paradox is resolved through logical thinking and action.0c/evidence0e

Below is an example of one of the correct outputs. Personally, I didn't expect it to work this well, but it is clear that it performs reasoning very thoroughly step-by-step.

Ultimately, this kind of output is generated for each question. As post-processing, I mechanically processed the text within the <answer> and <evidence> tags and submitted them.

Output Example (Question 17):

## Question
What was the reason the protagonist thought, "The Last Supper!"?

## Rewritten Question
In Mebae.txt, explain the reason/cause/motive/state of mind that led the protagonist to recognize/feel/think of it as "last" in relation to the expression/description/phrase "The Last Supper."

<thinking>
The original question and the rewritten question have almost the same meaning, but the rewritten question is more detailed and clearly indicates the scope of the answer. Specifically, it is required to explain the protagonist's state of mind in the scene where the words "The Last Supper" appear, and the reason why they felt it was "last."

The elements required for the answer are:
1. The specific context in which the words "The Last Supper" appear.
2. The protagonist's situation at the time (family, work, mental state, etc.).
3. Inference of the reason why they felt it was "last" (if there is no explicit description, infer from the preceding and following context).

The intent of the question is to decipher the psychology behind the protagonist's feelings and actions.

Strategies for identifying relevant parts within the novel:
1. Search using "The Last Supper" as a keyword.
2. Look for descriptions regarding the illness of the protagonist's child.
3. Look for descriptions regarding the protagonist's work.

Multiple interpretative possibilities:
1. Literal "Last Supper": A premonition that the child might die.
2. Metaphorical "Last Supper": A premonition of a major change in their own life or work, having braced for the child's death.
</thinking>

<step>1. Comprehensive identification of relevant parts (utilize keywords, synonyms, and context. List occurrences by checking the entire text multiple times in detail)</step>
<count>4</count>
"The Last Supper!" appears once.
Relevant part:
"Is it already too late, I wonder? This feeling came over me.
'The Last Supper!'
I thought suddenly as I was buying a can of Eagle brand milk halfway up the slope. At the house in Ushigome, various acquaintances had gathered. There, I also met a friend who had returned from the war front."

<step>2. Extraction and multi-layered organization of relevant information (ranking by importance, chronology, and causality)</step>
<count>3</count>
- The youngest child (Oshige) has a fever, and her condition is worsening.
- Called a village doctor, but a clear diagnosis could not be obtained.
- There is a gathering at a friend's house in Ushigome.
- About to buy milk on the way.
- Intending to ask for recommendations for a pediatrician.

<step>3. Logical assembly of information (resolving contradictions in a form that directly answers the question)</step>
<count>2</count>
The protagonist senses death because the youngest child's (Oshige) condition is worsening. Therefore, the phrase "The Last Supper!" came to mind while on the way to buy milk. This expresses the heartbreaking thought that the milk might be the last meal for Oshige.

<step>4. Selection of multiple supporting citations (prioritize the most relevant parts)</step>
<count>1</count>
"Is it already too late, I wonder? This feeling came over me.
'The Last Supper!'
I thought suddenly as I was buying a can of Eagle brand milk halfway up the slope."

<step>5. Concise and comprehensive summary of the answer (within 50 characters, capturing the core essence)</step>
<count>0</count>
<answer>Because he sensed his youngest child's death and thought the milk might be her last meal.</answer>

<reflection>
Successfully executed all steps. I understood the intent of the question, extracted, organized, and integrated appropriate information from the novel's content, and constructed a logical answer.
</reflection>
<reward>0.9</reward>

## Final Evaluation
Accuracy and completeness of the answer: High
推論過程の論理性と透明性:高い
文脈理解の深さと多角性:高い
想定外の解釈や可能性の考慮:十分
回答の簡潔さと明瞭性:高い
Final reward score: 0.9

<evidence>"Is it already too late, I wonder? This feeling came over me. 'The Last Supper!' I thought suddenly as I was buying a can of Eagle brand milk halfway up the slope." Because the youngest child's condition worsened and he felt death was near, he thought the milk he bought might be the last meal.</evidence>

Challenges and How I Overcame Them

Trial and Error in Prompt Design

Improving question accuracy required significant trial and error in prompt design. I repeatedly adjusted the prompts to find the optimal way for Gemini to return appropriate answers to complex questions. I was reminded once again of how crucial prompt design is for bringing out the performance of generative AI.

Issues with Output Reproducibility

LLM responses have "fluctuations," and there were many cases where output was inconsistent even for the same question. Multiple trials and evaluations were necessary to ensure accuracy, and I devised methods to select the most stable results to improve reproducibility. Through this process, I learned ways to enhance stability while accepting the inherent uncertainty of AI output.

Blocking Issues Due to Gemini's Safety Settings

Issues where content was blocked due to specific keywords or contexts occurred, which took time to address. Since blocking is affected not just by specific words but also by the overall structure of the question, I responded flexibly by adjusting the prompts and restructuring the question content. From this experience, I learned the importance of flexibly handling the impact of LLM safety settings.

Lessons Learned

Limitations and Potential of RAG Technology

RAG technology enables more sophisticated information retrieval compared to conventional vector search, but I also felt its limitations concerning complex questions and hallucinations. I realized that to maximize the potential of RAG, it is necessary to combine multiple search techniques and multi-stage reasoning approaches.

The Depth of Prompt Engineering

Many-shot prompts leveraging long context were effective in generating high-precision answers by taking advantage of Gemini's performance. I strongly felt that subtle adjustments to the prompt significantly affect the LLM's output, making the structure and expression of the prompt vital.

The Contribution and Importance of Community

Exchanging information and having technical discussions with other participants at events like the award ceremony was a valuable opportunity to gain new perspectives and hints for improvement. I reaffirmed that in the field of generative AI, sharing knowledge through the community contributes greatly to technological advancement.

Impressions

The unique challenge of RAG themed around novels provided a different perspective from daily business issues. There were many questions that couldn't be answered with simple search methods, and I felt the potential of RAG technology and LLMs once again. Challenging difficult problems that even humans would struggle with allowed me to experience the future of generative AI firsthand.
Furthermore, in the solution presentations by top winners at the award ceremony held on November 7th, there were several solutions that made me think, "They went that far...?", and there were many parts I couldn't fully comprehend, making me feel the depth of RAG. I am very much looking forward to the report detailing the top winners' solutions, which will be distributed to participants later. (By the way, my solution is also scheduled to be included, with almost the same content as this article.)

Future Prospects

  • Further Exploration of RAG Technology: I will continue researching RAG technology, aiming for its application in work and expansion into new projects.
  • Participation in Generative AI Competitions: I plan to challenge various generative AI competitions in the future to further enhance my skills.

Summary

Through the "RAG-1 Grand Prix," I was able to gain a lot of knowledge while facing various challenges. I hope to utilize the insights gained through this initiative to contribute to the advancement and business application of RAG technology in the future.

Discussion