Large language model interface for complex databases
This disclosure introduces a novel method and system for using a large language model (LLM) to create a convenient interface for a complex database. The system includes a custom prompt generator that creates custom prompts from natural language queries. The custom prompts are used to control how the LLM interacts with a database look-up tool. The database look-up tool provides queries to the database in a format understandable by the database and receives responses from the database. This system is useful for obtaining information that is not in a natural language, and thus, is poorly suited for being processed as an embedding by the LLM. Information obtained from the database is included in an answer produced by the LLM.
1 . A method for querying a database comprising:
receiving a natural language query containing a reference to a biological sequence;
generating a custom prompt from the natural language query that includes instructions to access a database look-up tool;
providing the custom prompt to a large language model (LLM);
extracting, by the LLM, the reference to the biological sequence and the instructions to access the database look-up tool;
retrieving the biological sequence from the database by the database look-up tool under control of the LLM, wherein the database look-up tool comprises three tools chained together and retrieving the biological sequence further comprises:
querying, by a first tool, the database with the reference to the biological sequence and retrieving a database-specific gene identifier;
querying, by a second tool, the database with the database-specific gene identifier and retrieving a sequence identifier; and
querying, by a third tool, the database with the sequence identifier and retrieving the biological sequence; and
generating an answer containing the biological sequence.
2 . The method of claim 1 , wherein the natural language query also contains a modifier and the extracting, by the LLM, further comprises modifying the reference to the biological sequence based on the modifier.
3 . The method of claim 1 , wherein the reference to the biological sequence is a common name of a gene.
4 . The method of claim 3 , wherein the first tool generates synonyms to the common name of the gene and submits one query for each synonym to the database.
5 . The method of claim 1 , wherein the custom prompt represents the database look-up tool by a variable.
6 . The method of claim 1 , further comprising:
determining that the reference to the biological sequence resolves to more than one biological sequence in the database, and
generating a response that requests additional description of the biological sequence.
7 . The method of claim 1 , wherein the sequence identifier is a transcript ID, a protein ID, or a GenInfo Identifier (GI) number.
8 . A system for querying a database comprising:
a processor;
a memory;
an interface configured to receive a natural language query containing a reference to a biological sequence and display an answer received from a large language model (LLM), the answer containing the biological sequence;
a custom prompt generator configured to generate a custom prompt from the natural language query containing the reference to the biological sequence and provide the custom prompt to the LLM, wherein the custom prompt includes instructions to access a database look-up tool; and
the database look-up tool configured to submit queries and obtain data from the database, the database look-up tool comprising:
a first tool that is configured to query the database with the reference to the biological sequence and receive a database-specific gene identifier; and
a second tool that is configured to query the database with the database-specific gene identifier and retrieve a sequence identifier.
9 . The system of claim 8 , wherein the interface also comprises an orchestration framework configured to connect the LLM to the custom prompt generator and to the database look-up tool.
10 . The system of claim 8 , wherein the custom prompt generator is further configured to generate the custom prompt based on a modifier contained in the natural language query such that the reference to the biological sequence is modified based on the modifier.
11 . The system of claim 8 , wherein the custom prompt generator is further configured to generate the custom prompt with a variable that represents the database look-up tool.
12 . The system of claim 8 , wherein the database look-up tool comprises a third tool that is configured to query the database with the sequence identifier and retrieve the biological sequence.
13 . The system of claim 8 , wherein the reference to the biological sequence is a common name of a gene.
14 . The system of claim 13 , wherein the first tool generates synonyms to the common name of the gene and submits one query for each synonym to the database.
15 . Computer-readable storage media comprising instructions that, when executed by a computing device, cause the computing device to perform actions comprising:
receiving a natural language query containing a reference to a biological sequence;
generating a custom prompt from the natural language query that includes instructions to access a database look-up tool;
providing the custom prompt to a large language model (LLM);
extracting, by the LLM, the reference to the biological sequence and the instructions to access the database look-up tool;
retrieving the biological sequence from a database by the database look-up tool under control of the LLM, wherein the database look-up tool comprises three tools chained together and retrieving the biological sequence further comprises:
querying, by a first tool, the database with the reference to the biological sequence and retrieving a database-specific gene identifier;
querying, by a second tool, the database with the database-specific gene identifier and retrieving a sequence identifier; and
querying, by a third tool, the database with the sequence identifier and retrieving the biological sequence; and
generating an answer containing the biological sequence.
16 . The computer-readable storage media of claim 15 , wherein the natural language query also contains a modifier and the extracting, by the LLM, further comprises modifying the reference to the biological sequence based on the modifier.
17 . The computer-readable storage media of claim 15 , wherein the custom prompt represents the database look-up tool by a variable.
18 . The computer-readable storage media of claim 15 , wherein the actions further comprise:
determining that the reference to the biological sequence resolves to more than one biological sequence in the database, and
generating a response that requests additional description of the biological sequence.
19 . The computer-readable storage media of claim 15 , wherein the reference to the biological sequence is a common name of a gene.
20 . The computer-readable storage media of claim 19 , wherein the first tool generates synonyms to the common name of the gene and submits one query for each synonym to the database.