From 9dd88dc0409065d1d22370f97dc668e93d9dea68 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Mon, 6 Nov 2023 14:16:24 -0800 Subject: [PATCH] Fixes for Bruces comments Signed-off-by: Matt Williams --- .../findArt.ts | 10 +++++----- .../generateSource.ts | 3 +-- .../readme.md | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/langchain-typescript-selfqueryingretrieval/findArt.ts b/examples/langchain-typescript-selfqueryingretrieval/findArt.ts index 66ae8a38..475360e5 100644 --- a/examples/langchain-typescript-selfqueryingretrieval/findArt.ts +++ b/examples/langchain-typescript-selfqueryingretrieval/findArt.ts @@ -27,12 +27,12 @@ const attributeInfo: AttributeInfo[] = [ ] -// Define the embeddings that will be used when adding the documents to the vector store +// Define the model used to generate embeddings, these capture the context of the input data const embeddings = new HuggingFaceTransformersEmbeddings({ modelName: "Xenova/all-MiniLM-L6-v2", }); -// Create the Ollama model +// Run the model using Ollama const llm = new Ollama({ model: modelName }) @@ -58,9 +58,9 @@ const findArt = async () => { // query from the LLM used to retrieve the documents { handleLLMEnd(output) { - console.log("llm end") - const outout = output.generations[0][0].text.replace(/\\"/gm, "'").replace(/\n/gm, "") - console.log(`output - ${JSON.stringify(outout, null, 2)}`) + console.log("This is the output from the LLM after it has come up with a filter") + const llmEndOutput = output.generations[0][0].text.replace(/\\"/gm, "'").replace(/\n/gm, "") + console.log(`output - ${JSON.stringify(llmEndOutput, null, 2)}`) } }, ]); diff --git a/examples/langchain-typescript-selfqueryingretrieval/generateSource.ts b/examples/langchain-typescript-selfqueryingretrieval/generateSource.ts index 4f4786c3..1fc96797 100644 --- a/examples/langchain-typescript-selfqueryingretrieval/generateSource.ts +++ b/examples/langchain-typescript-selfqueryingretrieval/generateSource.ts @@ -41,8 +41,7 @@ const fetchArtistWorkIds = async (artist: string): Promise => { const response = await fetch(artistURL); const json = await response.json(); const artistWorks: { id: number }[] = json.data; - const justIds = artistWorks.map((work) => work.id); - return justIds; + return artistWorks.map((work) => work.id); } const embedding = new HuggingFaceTransformersEmbeddings({ modelName: "Xenova/all-MiniLM-L6-v2", diff --git a/examples/langchain-typescript-selfqueryingretrieval/readme.md b/examples/langchain-typescript-selfqueryingretrieval/readme.md index 5cf0b54f..b331e32b 100644 --- a/examples/langchain-typescript-selfqueryingretrieval/readme.md +++ b/examples/langchain-typescript-selfqueryingretrieval/readme.md @@ -34,7 +34,7 @@ There are a few things you need to do to enable Self Query Retrieval. First, the ## The code -There are two main parts to the code. First there is a GenerateSource.ts file and then there is a FindArt.ts file. Let's look at GenerateSource first. +There are two main parts to the code. First there is a `GenerateSource.ts` file and then there is a `FindArt.ts` file. Let's look at GenerateSource first. ### GenerateSource @@ -108,4 +108,4 @@ To take this further, you could work on getting more out of the dataset. It turn Maybe it makes more sense to move the artist name and title of the work into the document itself. Then add some more metadata (there are at least 100 other attributes in the raw API that aren't used in this example.) -Also try different models. In testing so far, it seems that codellama performs the best, but when a new model comes out you might try that. \ No newline at end of file +Also try different models. In testing so far, it seems that `codellama` produces more reliably useable filters. It's not perfect and can still create a filter that won't find anything. When a new code model comes out, you might try that to see if it performs better.