category
stringclasses
107 values
title
stringlengths
15
179
question_link
stringlengths
59
147
question_body
stringlengths
53
33.8k
answer_html
stringlengths
0
28.8k
__index_level_0__
int64
0
1.58k
implement RAG
Connection error when using langchain_community.vectorstores.faiss.FAISS
https://stackoverflow.com/questions/78147781/connection-error-when-using-langchain-community-vectorstores-faiss-faiss
<p>I found a methodology to use RAG (retrieval-augmented generation) with a Large Language Model (LLM) to answer question about a provided transcriptions. Here is the GitHub link: <a href="https://github.com/ingridstevens/whisper-audio-transcriber" rel="nofollow noreferrer">https://github.com/ingridstevens/whisper-audi...
1,434
implement RAG
How can I implement Auto-merging Retriever (aka Parent Document Retriever) directly with Pinecone (or other VectorDB)?
https://stackoverflow.com/questions/77719901/how-can-i-implement-auto-merging-retriever-aka-parent-document-retriever-direc
<p>Context: I'm trying to implement an advanced RAG pipeline that uses <a href="https://docs.llamaindex.ai/en/latest/examples/retrievers/auto_merging_retriever.html" rel="nofollow noreferrer">Auto-merging Retriever</a> (aka <a href="https://python.langchain.com/docs/modules/data_connection/retrievers/parent_document_re...
1,435
implement RAG
Returning document sources using LCEL
https://stackoverflow.com/questions/78072019/returning-document-sources-using-lcel
<p>I am implementing the example provided here: <a href="https://python.langchain.com/docs/templates/neo4j-advanced-rag" rel="nofollow noreferrer">https://python.langchain.com/docs/templates/neo4j-advanced-rag</a></p> <p>However, I'd like to enhance the functionality to return the sources (aka context) that was supplie...
<p>Not sure why my question received negative vote, but for anyone looking for this, posting the answer: Modified the code as below to add the context as well to the chain</p> <pre><code>chain = ( { &quot;context&quot;: itemgetter(&quot;question&quot;) | retriever , &quot;question&quot;: itemgetter(&quot;questi...
1,436
implement RAG
How to Implement Chat-Specific Vector Embeddings and Manage Token Limits in a Serverless Chat Application Using Azure?
https://stackoverflow.com/questions/78917444/how-to-implement-chat-specific-vector-embeddings-and-manage-token-limits-in-a-se
<p><strong>Question:</strong></p> <p>I'm developing a chat application similar to ChatGPT using Azure's serverless model. The application includes several functionalities such as document upload, vector embeddings storage, and AI-powered responses. However, I'm facing multiple challenges and would appreciate any guidan...
1,437
implement RAG
How to filter results to LLM from graph database based on source file names?
https://stackoverflow.com/questions/78853538/how-to-filter-results-to-llm-from-graph-database-based-on-source-file-names
<p>I'm trying to build a Graph RAG with hybrid retrieval for technical documentation files. The answers need to be found for version specific documentation files. I'm trying to achieve this by filtering graph and vector queries based on file names. However, I'm unable to implement source file filtering for Graph RAG im...
<p>The <code>{limit: 2}</code> argument to <code>db.index.fulltext.queryNodes</code> produces at most 2 nodes for the rest of your query to use.</p> <p>Either remove the <code>{limit: 2}</code> argument entirely, or increase the <code>2</code> to a comfortably large enough number to make it much more likely that you ge...
1,438
implement RAG
LLamaIndex Workflow Context Memory Management
https://stackoverflow.com/questions/79085691/llamaindex-workflow-context-memory-management
<p>I am looking for a way to implement a RAG Chatbot which should keep the previous answer and questions from the current session in a short term memory and be able to answer followup question, I do not see anything from the documentation on how to implement that, I saw the chat engine documentation but saw no examples...
<p>Kong Nopwattanapong published a blog post with regards to <a href="https://medium.com/credera-engineering/build-a-simple-rag-chatbot-with-langchain-b96b233e1b2a" rel="nofollow noreferrer">Building a simple RAG chatbot with LangChain</a>.</p> <p>Nopwattanapong concluded, the model isn’t perfect and there are still ma...
1,439
implement RAG
LangChain error: &quot;Groq does not currently support tool_choice=&#39;any&#39;. Should be one of &#39;auto&#39;, &#39;none&#39;, or the name of the tool to call.&quot;
https://stackoverflow.com/questions/78926872/langchain-error-groq-does-not-currently-support-tool-choice-any-should-be-o
<p>Here's my issue:</p> <p>I was using Groq API with LLama 3.1 70B model to implement agentic RAG through LangGraph. For that, I had to install <code>langchain_groq</code> library. I installed the most updated one using <code>pip install -U langchain_groq</code>. Then I used the following code to load the model into a ...
<p>You're looking at the LangChain <code>0.1</code> documentation while you're using the LangChain <code>0.2</code> SDK.</p> <p>To check your LangChain Python SDK version, run the following command in the terminal:</p> <pre><code>pip show langchain </code></pre> <p>For LLM provider specifics, see the <a href="https://p...
1,440
implement RAG
CSS | Ordered list in single vertical column above list item
https://stackoverflow.com/questions/32657851/css-ordered-list-in-single-vertical-column-above-list-item
<p>i'm looking to create an ordered list (decimal) in which all the items are rag-left aligned with their numerical header. for example:</p> <blockquote> <blockquote> <p>List</p> <p>1.</p> <p>This is list item 1</p> <p>2.</p> <p>This is list item 2</p> <p>3.</p> ...
<p>As @Imgonzalves pointed out --- </p> <p>HTML</p> <pre><code>&lt;ol&gt; &lt;li&gt;&lt;span&gt;list item&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;list item&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;list item&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; </code></pre> <p>CSS</p> <pre><code>ol li span { ...
1,441
implement RAG
Is there a way to interrupt text generation in an transformers LLM call?
https://stackoverflow.com/questions/78084171/is-there-a-way-to-interrupt-text-generation-in-an-transformers-llm-call
<p>I'm creating a RAG chatbot that uses the langchain and transformers libraries to generate responses to user queries using an LLM plugged into a vector index. The chatbot will live in a streamlit interface.</p> <p>I want to implement a way for the user to interrupt the LLM's <code>generate()</code> function if the ou...
1,442
implement RAG
Probably a really simple thing but I can&#39;t seem to pass an argument into my Javascript function
https://stackoverflow.com/questions/70411336/probably-a-really-simple-thing-but-i-cant-seem-to-pass-an-argument-into-my-java
<p>I am very new to JS I just created my very first web app but I am having trouble tidying up my code.</p> <p>My HTML has 3 range sliders I take the value from each and change the color of the thumb depending on that value (RAG). It works fine the way I have implemented it but I have repeated myself quite a bit.</p> <...
1,443
implement RAG
OpenAIEmbeddings works fine but AzureOpenAIEmbeddings gives error: &#39;str&#39; object has no attribute &#39;create&#39;
https://stackoverflow.com/questions/78733721/openaiembeddings-works-fine-but-azureopenaiembeddings-gives-error-str-object
<p>I am implementing simple RAG using AzureOpenAI. It was working fine till I was directly using the OpenAIEmbeddings but when I deployed &quot;text-embedding-ada-002&quot; model on Azure and tried using the embeddings with that, it shows the error: 'str' object has no attribute 'create'</p> <pre><code>import openai fr...
<p>I could able to figure out that I need to provide the proxy as it is running behind a firewall:</p> <pre><code> embeddings = AzureOpenAIEmbeddings( azure_deployment=os.getenv(&quot;AZURE_OPENAI_EMBEDDING_MODEL_NAME&quot;), openai_api_version=os.getenv(&quot;AZURE_OPENAI_API_VERSION&quot;), a...
1,444
implement RAG
llama_index crashes with HuggingFaceEmbedding
https://stackoverflow.com/questions/78348493/llama-index-crashes-with-huggingfaceembedding
<p>I am trying to build a RAG pipeline using <code>llama_index</code>. One of the first steps is to choose an embedding model that will be used for a <code>VectorStoreIndex</code>. My current implementation looks like this:</p> <pre class="lang-py prettyprint-override"><code>from llama_index.core import Settings from l...
<p>You have to install not just <code>pip install llama-index</code> and <code>pip install openai</code> but also <code>pip install llama-index-embeddings-huggingface</code>.</p> <p>Alternatively, it is sufficient to install <code>llama-index</code> only, but then you have to adjust your import statement:</p> <pre clas...
1,445
implement RAG
Stream output using VLLM
https://stackoverflow.com/questions/78815643/stream-output-using-vllm
<p>I am working on a RAG app, where I use LLMs to analyze various documents. I'm looking to improve the UX by streaming responses in real time.<br /> a snippet of my code:</p> <pre class="lang-py prettyprint-override"><code>params = SamplingParams(temperature=TEMPERATURE,                     min_tokens=128,  ...
<p><a href="https://docs.vllm.ai/en/stable/dev/engine/async_llm_engine.html#" rel="nofollow noreferrer">AsyncLLMEngine</a> will help you.</p> <p>You can also refer to vLLM's <a href="https://github.com/vllm-project/vllm/blob/main/vllm/entrypoints/api_server.py#L56" rel="nofollow noreferrer">aip_server.py</a></p>
1,446
implement RAG
Playwright not displaying exception when locator not exists in DOM
https://stackoverflow.com/questions/76750187/playwright-not-displaying-exception-when-locator-not-exists-in-dom
<p>I am new to Playwright, I am trying to implement Playwritght +NUnit framework. I currently facing 2 issues,</p> <p>a. When I have give any invalid locator (eg: xpath, cssselector), Playwright not throwing exception message, it's continue next step, even I try in try/catch block it not print exception.</p> <pre><code...
<p>Option A with an <code>await</code> should work for you. Your code is not failing because we are not awaiting for the action that might fail.</p> <pre><code>await _page.Locator(&quot;input#email1234&quot;).ClickAsync(); </code></pre>
1,447
implement RAG
How do I use MergeDataLoader to tolerate multiple files that could be in either PDF or docx format?
https://stackoverflow.com/questions/79370058/how-do-i-use-mergedataloader-to-tolerate-multiple-files-that-could-be-in-either
<p>I am writing a RAG chatbot that retrieves information from a given list of documents. The documents can be found in a set folder, and they could be either .pdf or .docx. I want to merge all the documents using the same vector store, but I am running into trouble with the MergeDataLoader because any given file could ...
1,448
implement RAG
Uploading documents to Azure AI search
https://stackoverflow.com/questions/78153996/uploading-documents-to-azure-ai-search
<p>I am implementing RAG using azure AI search. I have created the index nd have 2605 document chunks in all to upload to the index. The peculiar behaviour that I have observed is :</p> <ol> <li>i cannot upload all 2605 chunks in one go.</li> <li>I try passing these in batch sizes of 600, by loooping over and passing 6...
<p>I have used the Python SDK to upload documents, and they uploaded successfully. I tried with 3k and 10k documents, and it successfully uploaded all those documents to the index in one go.</p> <p>Refer to the code below.</p> <pre class="lang-py prettyprint-override"><code>import os index_name = &quot;hotels-2&quot; ...
1,449
implement RAG
How to make dynamic API calls based on user input in a Gemini application python nlp?
https://stackoverflow.com/questions/78707861/how-to-make-dynamic-api-calls-based-on-user-input-in-a-gemini-application-python
<p>I'm working on a Gemini application where I need to make dynamic API calls based on user input. Specifically, I want to perform different API requests depending on the user's query. For example, if the user asks for the latest news, the application should make an API call to a news service. Similarly, if the user wa...
<p>I suggest using a dictionary, basically what you u are looking to do is something called a &quot;strategy pattern&quot;. You want to choose a different &quot;strategy&quot; in your case api based on different input.</p> <p>so the way it will look is you have a dictionary {&quot;news&quot;: &quot;news-url&quot;, &quo...
1,450
implement RAG
Problem Setting up a FAISS vector memory in Python with embeddings
https://stackoverflow.com/questions/79315980/problem-setting-up-a-faiss-vector-memory-in-python-with-embeddings
<p>I'm trying to run an LLM locally and feed it with the contents of a very large PDF. I have decided to try this via a RAG. For this I wanted to create a vectorstore, which contains the content of the pdf. however, I have a problem here when creating, which I can not solve, because I am still quite new in this area.</...
1,451
implement RAG
Why does Bedrock and CrewAI produce incomplete responses?
https://stackoverflow.com/questions/78811050/why-does-bedrock-and-crewai-produce-incomplete-responses
<p>Im writing a crewAI backed by AWS Bedrock. application that generates code.</p> <p>The issue Im seeing is that it produces incomplete responses. The code produce some python functions but will</p> <ol> <li>Produce an incomplete function that is syntacticly incorrect.</li> <li>Produce not enough code to compelete the...
1,452
implement RAG
Unable to ship my flutter app with a pre-built ObjectBox database
https://stackoverflow.com/questions/79626120/unable-to-ship-my-flutter-app-with-a-pre-built-objectbox-database
<p>I'm unable to <a href="https://docs.objectbox.io/faq#can-i-ship-my-app-with-a-pre-built-database" rel="nofollow noreferrer">ship my Flutter app with a pre-built database</a>. Below is my approach; <em><strong>it would be greatly appreciated if this intent of shipping a database and the steps involved are validated. ...
<p>Before I answer: it's not officially supported to use an ObjectBox database (pre-)built with one SDK with a different SDK. There may be subtle differences in the platforms and SDKs.</p> <p>Anyhow, if you want to attempt this (and again, it might not work): the &quot;does not match existing UID&quot; errors suggest y...
1,453
implement RAG
Azure Cognitive Search - Filter is not working
https://stackoverflow.com/questions/77996066/azure-cognitive-search-filter-is-not-working
<p>I have RAG and am trying to implement filtering by keywords/phrases as shown below:</p> <pre><code> public SearchOptions? CreateSearchOptions( int searchTypeInt, int k, ReadOnlyMemory&lt;float&gt; embeddings, ...
<p>I'm not sure what the &quot;SearchFilter.Create()&quot; function does, but assuming it doesn't rewrite the input string, the &quot;ct&quot; operator used in</p> <pre><code>$&quot;SegmentText ct '{filter}'&quot; </code></pre> <p>doesn't exist. The filter language is documented here: <a href="https://learn.microsoft.c...
1,454
implement RAG
I am using LangChain4j to develop a knowledge base and encountered the &quot;different vector dimensions 1024 and 384&quot;
https://stackoverflow.com/questions/79557012/i-am-using-langchain4j-to-develop-a-knowledge-base-and-encountered-the-differen
<p>I want to know if there are any other settings required for pgvector or what content needs to be set in the code to enable pgvector to support higher vector dimensions. I found on the official website that pgvector can support vector dimensions up to 2000.The pgvector version is pgvector/pgvector:pg17</p> <p>This mo...
<p>you need to change <code>.dimension(1024)</code> to <code>.dimension(384)</code>.</p> <p>You can always get the dimention of your <code>EmbeddingModel</code> by calling <code>EmbeddingModel.dimension()</code>.</p>
1,455
implement RAG
Azure AI search fields mapping JSON and retrievable fields
https://stackoverflow.com/questions/78546836/azure-ai-search-fields-mapping-json-and-retrievable-fields
<p>I'm currently implementing RAG on Azure using OpenAI and Azure AI Search, formerly known as Cognitive Services. I have around 50-65 JSON files that I need to search on my enterprise data. It turns out that in the referencing of the chatbot, I'm only getting the text &quot;citation&quot; and I'm trying to retrieve th...
<p>Import data and with index definition both way you can do.</p> <p>In portal, after you clicking on import data you will get an option <strong>connect to your data</strong> there you need to configure parsing mode as json.</p> <p><img src="https://i.imgur.com/m3sXom5.png" alt="enter image description here" /></p> <p>...
1,456
implement RAG
Optimizing Django ORM for Hybrid Queries (PostgreSQL + Vector Similarity Search)
https://stackoverflow.com/questions/79569409/optimizing-django-orm-for-hybrid-queries-postgresql-vector-similarity-search
<p>I'm implementing a RAG (Retrieval-Augmented Generation) system that requires combining traditional Django ORM filtering with vector similarity searches. The specific workflow needs to:</p> <p>First filter products by standard relational fields (e.g., category=&quot;books&quot;)</p> <p>Then perform vector similarity ...
1,457
implement RAG
Inquiry About Intent Feature in OpenAI and Azure AI Search Integration
https://stackoverflow.com/questions/79007855/inquiry-about-intent-feature-in-openai-and-azure-ai-search-integration
<p>I am interested in understanding the logic behind the intent feature in the integration between OpenAI's chat completions and Azure AI Search. Specifically, I noticed that when appending and sending chat history for retrieval-augmented generation (RAG), there is a feature in the response named &quot;intent.&quot; Th...
<p>It is the detected intent from chat history, check <a href="https://learn.microsoft.com/en-us/azure/ai-services/openai/references/on-your-data?tabs=python#context" rel="nofollow noreferrer">this</a> Getting intent considering all the chat history you are giving.</p> <p>azure openai did not provided how it is creatin...
1,458
implement RAG
Fine-Tuning LLMs: CUDA OOM Errors Despite Various Optimization Techniques
https://stackoverflow.com/questions/78949634/fine-tuning-llms-cuda-oom-errors-despite-various-optimization-techniques
<p>I'm working on fine-tuning an LLM to build a fantasy football league model. The goal is to have the model output a team with high potential (hopefully) given a round of games. I have built an RAG dataset and implemented custom loss functions and metrics to fine-tune the model.</p> <p><strong>Problem</strong>: Regard...
1,459
implement RAG
How to combine Parent Document Retriever with Self Query Retriever with Lang Chain framework
https://stackoverflow.com/questions/78091831/how-to-combine-parent-document-retriever-with-self-query-retriever-with-lang-cha
<p>I have implemented a Self Query retriever (<a href="https://python.langchain.com/docs/modules/data_connection/retrievers/self_query" rel="nofollow noreferrer">https://python.langchain.com/docs/modules/data_connection/retrievers/self_query</a>) for my RAG model, and it works fine. I can retrieve specific chunks of do...
1,460
implement RAG
Box2d javascript revolute joint same anchor point different bodies
https://stackoverflow.com/questions/42590376/box2d-javascript-revolute-joint-same-anchor-point-different-bodies
<p>I'm trying to make a rag doll and I have 2 hip joints implemented as revolute joints. The problem is that they are not responding as independent segments. It seems like one of them is holding up the other one. It looks like this: <a href="https://i.sstatic.net/PQwd3.png" rel="nofollow noreferrer"><img src="https://i...
1,461
implement RAG
How to pass custom prompt variables in a chainlit app?
https://stackoverflow.com/questions/78114723/how-to-pass-custom-prompt-variables-in-a-chainlit-app
<p>I want to add a simple chat UI to my RAG based chatbot. All the materials(one <a href="https://medium.com/@cleancoder/build-a-chatbot-in-minutes-with-chainlit-gpt-4-and-langchain-7690968578f0" rel="nofollow noreferrer">example</a>) I came across online have a very simple prompt template with <code>question</code> an...
1,462
implement RAG
Slow Response Time in Cricket-Specific Chatbot Using CrewAI
https://stackoverflow.com/questions/79335247/slow-response-time-in-cricket-specific-chatbot-using-crewai
<p>I’m building a cricket-specific chatbot using CrewAI. The chatbot is designed to answer queries based on historical cricket data in CSV files and real-time data from APIs. The data is stored in an SQL database. However, I am experiencing slow response times for answering user queries, with response times ranging fro...
1,463
implement RAG
DSPy: How to get the number of tokens available for the input fields?
https://stackoverflow.com/questions/78743278/dspy-how-to-get-the-number-of-tokens-available-for-the-input-fields
<p>This is a cross-post from <a href="https://github.com/stanfordnlp/dspy/issues/1245" rel="nofollow noreferrer">Issue #1245 of DSPy GitHub Repo</a>. There were no responses in the past week, am I am working on a project with a tight schedule.</p> <p>When running a DSPy module with a given signature, I am interested in...
<p>If you need really good compression , I’ve used on ChatGPT “SentenceSqueezer”, it usually compresses in neighborhood 60-85% of instruction sets and it’s so simple, guaranteed not to lose context because it makes an acronym out of each sentence or line , tell it to leave periods in there place or whatever you desire,...
1,464
implement RAG
What is solution of missing deployment name and replaced by model on Azure Ai Studio?
https://stackoverflow.com/questions/78905182/what-is-solution-of-missing-deployment-name-and-replaced-by-model-on-azure-ai-st
<p>I've been using Azure AI Studio and Azure OpenAI Studio for a while now, and I'm currently working on implementing a RAG (Retrieval-Augmented Generation) technique using Prompt Flow. However, I've encountered an issue.</p> <p>Previously, in Azure AI Studio's Prompt Flow, there was an option to connect to Azure OpenA...
1,465
implement RAG
How to stream openai response with metadata
https://stackoverflow.com/questions/79323421/how-to-stream-openai-response-with-metadata
<p>I have implemented streaming response in our rag(Retrieval-Augmented-Generation) chatbot. However, I am unable to figure out a proper way to send the metadata information with the streaming response.If, we do not use streaming, we can send the metadata with the message response in JSON format. But, in streaming resp...
1,466
implement RAG
Creating knowledge graph index out of a XML (DEXPI) file
https://stackoverflow.com/questions/77613200/creating-knowledge-graph-index-out-of-a-xml-dexpi-file
<p><strong>Context:</strong></p> <p>I have a XML file (DEXPI) and I want to use it as a data source to implement Retrieval Augmented Generation (RAG) system using <code>llama-index</code> to fetch the correct context against any natural language query.</p> <p><strong>Current Issue:</strong></p> <ul> <li>I cannot use th...
1,467
implement RAG
How can I swap an instance of ChatMessageHistory with an instance of ConversationBufferWindowMemory? Python, Langchain
https://stackoverflow.com/questions/78518917/how-can-i-swap-an-instance-of-chatmessagehistory-with-an-instance-of-conversatio
<p>I implemented <a href="https://python.langchain.com/v0.1/docs/use_cases/question_answering/chat_history/" rel="nofollow noreferrer">this use case</a> from langchain to add chat history to my RAG to contextualize questions that may be incomplete. Everything works fine but now I would like to use only the last x messa...
<p>This will probably solve your problem: it uses a FAISS index for RAG but can be easily adapted for your case.</p> <pre><code>def runPrompt(): history=[] memory = ConversationBufferMemory( memory_key='chat_history', return_messages=True, output_key='answer') # Create a conversation chain code_llm = V...
1,468
implement RAG
Llamaindex TS SimpleDirectoryReader works locally but not on AWS EC2 server
https://stackoverflow.com/questions/78894391/llamaindex-ts-simpledirectoryreader-works-locally-but-not-on-aws-ec2-server
<p>I have a node express server setup for a llamaindex RAG system. Locally I'm able to generate a VectorIndexStore from a directory I've called <code>./data</code> and run queries successfully. However, I've just cloned the repo onto my AWS EC2 server and even though it boots up successfully it seems that the <code>Sim...
1,469
implement RAG
use embeddings stored in vector db to reduce work for LLM generating response
https://stackoverflow.com/questions/78023750/use-embeddings-stored-in-vector-db-to-reduce-work-for-llm-generating-response
<p>I'm trying to understand what the correct strategy is for storing and using embeddings in a vector database, to be used with an LLM. If my goal is to reduce the amount of work the LLM has to do when generating a response, (So you can think of a RAG implementation where I've stored text, embeddings I've created usin...
1,470
implement RAG
How to continue previous conversations with transcript data in Bot Framework and WebChat
https://stackoverflow.com/questions/79184231/how-to-continue-previous-conversations-with-transcript-data-in-bot-framework-and
<p>Solutions like ChatGPT, Perplexity, and Copilot provide ways for users to reopen older conversations. I am trying to implement a similar feature using the Bot Framework and WebChat.</p> <p><strong>My setup</strong></p> <p>Last year I built a RAG-type chatbot for internal use at a company, using Bot Framework and Web...
<p>If you are using BotFramework-Webchat, then you can pass an array of activities into the store when it is created. The array is placed within the first set of curly brackets.</p> <p>Activities array:</p> <pre class="lang-js prettyprint-override"><code>const activities = [ { ...first activity... }, ...
1,471
implement RAG
Langchain4j pgvector implementation as an EmbeddingStore?
https://stackoverflow.com/questions/77968544/langchain4j-pgvector-implementation-as-an-embeddingstore
<p>I'm building a RAG based AI service using Langchain4j. I have one microservice that is ingesting and saving my documents (pdfs, csv, words...) in my PostgreSQL DB (with vector extension) as embeddings.</p> <p>From the other hand I'm building another microservice to hold the AI conversation logic.</p> <p>To do this I...
<p>Not sure if you've already fixed your blockers. I ran into something similar with MongoDb, and although it's not a new collection being created in the database when using the MongoDB implementation of the Embedded Store, it happens to be another issue with ObjectId's. My project was underway, until I realized I coul...
1,472
implement RAG
Llama 3 chat_history not working as expected
https://stackoverflow.com/questions/78808357/llama-3-chat-history-not-working-as-expected
<p>I'm using Langchain agent to perform a RAG upon my own knowledge. The usual QnA flow works perfectly, but when it comes to chat_history the bot is not performing as expected. It does not re-create a user query with previous questions content when needed. Below is the base prompt that I'm usinng.</p> <p>&lt;&gt; Assi...
1,473
implement RAG
What the script editor accepts and what Google Sheets accepts can be different?
https://stackoverflow.com/questions/55381362/what-the-script-editor-accepts-and-what-google-sheets-accepts-can-be-different
<p>So I've been trying to build an AADD(range, range) function. It's not complete so don't rag me about that. What's bothering me at the moment is that what the Script Editor says in meaningful code and what Google Sheets will run appears to be different.</p> <p>First of all here's the tester:</p> <pre><code>function...
1,474
implement RAG
Gannt Chart with single line for all project phases
https://stackoverflow.com/questions/77519040/gannt-chart-with-single-line-for-all-project-phases
<p>I am a new user to Power Bi and I am hoping the community may be able to help me with my problem.</p> <p>In Power Bi I want to create a dashboard that will contain a gantt view of my projects refecltive of all the different stages/phases within the lifecycle in one line across the time horizon.</p> <p>My data table ...
<p>If your desired result is something like the following:</p> <p><a href="https://i.sstatic.net/yY6rF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yY6rF.png" alt="enter image description here" /></a></p> <p>Add the following fields:</p> <p><a href="https://i.sstatic.net/7Sjyn.png" rel="nofollow noref...
1,475
implement RAG
Q&amp;A using Retrieval-Augmented Generation with Langchain
https://stackoverflow.com/questions/78383658/qa-using-retrieval-augmented-generation-with-langchain
<p><code>I have been doing a POC to implement RAG driven model for my AI/ML use case.</code><br /> <code>The use case is to &quot;</code><strong><code>Find Similar and duplicate controls by comparing each ID with every other ID, Generate similarity scores and list the pairs which exceeds a threshold of 80-87 for simila...
<p>When you say:</p> <blockquote> <p>Blockquote My expected outcome is to print the list of Similar and Duplicate pairs from the data , it has around 3500+ data.</p> </blockquote> <p>First, in your prompt you need to be explicit on how you want the output to be.</p> <p>Like:</p> <blockquote> <p>Blockquote Output the re...
1,476
implement RAG
How can i sort vector of vectors by other vector
https://stackoverflow.com/questions/76434205/how-can-i-sort-vector-of-vectors-by-other-vector
<p>I am making a genetic algorithm and I have a sorting problem: I have such a class, it is represented as std::vector</p> <pre><code>class GA_Class { public: float Fitness = 0.0f; bool Parent = 0; }; typedef std::vector&lt;GA_Class&gt; GA_Vector; </code></pre> <p>Also I have a main class</p> <pre><code>class GA_Popu...
<p>I redid my classes and used range(<a href="https://github.com/ericniebler/range-v3" rel="nofollow noreferrer">https://github.com/ericniebler/range-v3</a>)</p> <p>Class</p> <pre><code>class GA_Population { private: std::vector&lt;std::vector&lt;ZydisDisassembledInstruction&gt;&gt; PopulationSetInstrs; ...
1,477
implement RAG
Integrating input rails and output rails into chat bot via Runnable Rails
https://stackoverflow.com/questions/78904449/integrating-input-rails-and-output-rails-into-chat-bot-via-runnable-rails
<p>I've been working on developing and safeguarding a chat bot based on RAG - model and NeMo - Guardrails. I'm trying to integrate output rails alongside input rails. But I'm having trouble while doing so. The issue lies in YAML and COLANG contents because the input and output rails are not being initialized. I'm using...
<p>There is syntax and conceptual incorrect implementation that i can notice, to fix it you can remove this from your COLANG_CONTENT</p> <pre><code>define self_check_input user express greeting bot respond appropriate question define self_check_output user ask inappropriate question bot respond inappropriate quest...
1,478
implement RAG
Attempt to redefine node p[1,1] When adding covariates to beta-binomial mixture model
https://stackoverflow.com/questions/71720266/attempt-to-redefine-node-p1-1-when-adding-covariates-to-beta-binomial-mixture
<p>I keep getting the above error when I try adding detection covariates on a beta-binomial N-mixture model in rags. According to Royle(2004). A binomial N mixture model can be used to model abundance data arising from repeat count surveys. The number of individuals on a site can be modeled by a Poisson <em>[For simpl...
<p><strong>Note: I edited my question to match the parameters on the equations I wrote</strong></p> <p>I was getting this error because, my detection model is not properly specified. Two processes here are trying to determine <code>pit[i,t]</code> the first is <code>pit[i,t]~ dbeta(1,1)</code></p> <p>then</p> <p><code>...
1,479
implement quantization
Dequantize values to their original prior to quantization
https://stackoverflow.com/questions/62450062/dequantize-values-to-their-original-prior-to-quantization
<p>The paper &quot;Natural Language Processing with Small Feed-Forward Networks&quot; <a href="https://arxiv.org/pdf/1708.00214.pdf" rel="nofollow noreferrer">https://arxiv.org/pdf/1708.00214.pdf</a> states:</p> <p><a href="https://i.sstatic.net/gZXla.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gZXla...
<p>What they are doing in the paper is roughly this:</p> <pre><code>import numpy as np b = 128 embedding_matrix = np.array([[20000,3000,1000,1000],[1999999,20000,1999999,1999999], [20000,3000,1000,1000]]) scales = (np.abs(embedding_matrix).max(axis=1) / (b-1)).reshape(-1, 1) quantized = (embedding_matrix / scales + b...
1,480
implement quantization
Implementing custom h264 quantization for Ffmpeg?
https://stackoverflow.com/questions/42492862/implementing-custom-h264-quantization-for-ffmpeg
<p>I have a Raspberry Pi, and I'm livestreaming using FFmpeg. Unfortunately my wifi signal varies over the course of my stream. I'm currently using raspivid to send h264 encoded video to the stream. I have set a constant resolution and FPS, but have not set bitrate nor quantization, so they are variable.</p> <p>Howeve...
1,481
implement quantization
Matlab: Help in implementing quantized time series
https://stackoverflow.com/questions/28734781/matlab-help-in-implementing-quantized-time-series
<p>I am having trouble implementing this code due to the variable <code>s_k</code> being logical 0/1. In what way can I implement this statement?</p> <p><img src="https://latex.codecogs.com/png.latex?x%28t%29%20%3D%20%5Csum_%7Bk%3Dt%7D%5E%7Bt&plus;N-1%7D%20s_k%202%5E%7B-%28k-n&plus;1%29%7D" alt=""></p> <p><code>s_k</...
<p>You've generated the random <code>logical</code> sequence, which is great. You also need to know <code>N</code>, which is the total number of points to collect at one time, as well as a list of time values <code>t</code>. Because this is a discrete summation, I'm going to assume the values of <code>t</code> are di...
1,482
implement quantization
Quantized Neural Network Support is gone in TensorFlow 1.0v?
https://stackoverflow.com/questions/43003778/quantized-neural-network-support-is-gone-in-tensorflow-1-0v
<p>I'm trying to implement <strong>quantization in neural network</strong> with tensorflow r1.0 and is not working i.e. Bazel BUILD files doesn't find targets and some other files.</p> <p>I realize that in the version <a href="https://github.com/tensorflow/tensorflow/tree/r0.9/tensorflow/contrib/quantization" rel="n...
1,483
implement quantization
Is it possible to perform quantization on densenet169 and how?
https://stackoverflow.com/questions/74612146/is-it-possible-to-perform-quantization-on-densenet169-and-how
<p>I have been trying to performing quantization on a densenet model without success. I have been trying to implement pytorch post training static quantization. Pytorch has quantized versions of other models, but does not have for densenet. Is it possible to quantize the densenet architecture.</p> <p>I have searched fo...
<p>Here's how to do this on DenseNet169 from torchvision:</p> <pre class="lang-py prettyprint-override"><code>from torch.ao.quantization import QuantStub, DeQuantStub from torch import nn from torchvision.models import densenet169, DenseNet169_Weights from tqdm import tqdm from torch.ao.quantization import HistogramObs...
1,484
implement quantization
How to do quantization in JPEG compression?
https://stackoverflow.com/questions/44427748/how-to-do-quantization-in-jpeg-compression
<p>I am studying on the JPEG compression algorithm. I followed some simple version instruction to implement it in MatLab and I stuck at the quantization process.</p> <p>So in JPEG, I use 8x8 blocks as a unit to perform the forward transform then quantize each block based on a quantization matrix (or divide by a number...
<p>OK, I have figured it out.</p> <p>The problem is not about the algorithm and my DCT/Quantization implementation. </p> <p>The problem is I am using im2double to convert my image. From the MatLab official documentation,</p> <blockquote> <p>I2 = im2double(I) converts the intensity image I to double precision, re...
1,485
implement quantization
having trouble when implementing the interface &#39;Quantizer&#39; and &#39;Drawer&#39; of GIF
https://stackoverflow.com/questions/70474890/having-trouble-when-implementing-the-interface-quantizer-and-drawer-of-gif
<p>In <code>image/draw</code>, <code>Quantizer</code> and <code>Drawer</code> are defined like this:</p> <pre class="lang-golang prettyprint-override"><code>type Quantizer interface { Quantize(p color.Palette, m image.Image) color.Palette } type Drawer interface { Draw(dst Image, r image.Rectangle, src image....
<pre class="lang-golang prettyprint-override"><code>type quantizer struct { indexingMap *IndexingMap } func (q *quantizer) Quantize(p color.Palette, img image.Image) color.Palette { // do sth // q.indexingMap = sth } type drawer struct { q *quantizer } func (d drawer) Draw(dstOri draw.Image, rect image....
1,486
implement quantization
Quantization scheme for Convolutional Neural Network 8-bit quantization in tensorflow
https://stackoverflow.com/questions/60872726/quantization-scheme-for-convolutional-neural-network-8-bit-quantization-in-tenso
<p><a href="https://i.sstatic.net/4R18J.png" rel="nofollow noreferrer">Tensorflow code for quantization</a> From all the papars i have reffered for CNN quantization the quantization scheme is stated as </p> <p>step size = range/255 for 8-bit here range = xmax-xmin but as shown in the image in the tensorflow implement...
<p>This is because the code you are pointing to is for symmetric quantization where the range needs to be the same on both sides of 0. So the "range" variable in that code really refers to half of the entire floating point range.</p> <p>for instance, min_value = -1 max_value = 2</p> <p>range = std::max(abs(-1), abs(2...
1,487
implement quantization
Different results between quantized TFlite model to its implementation using Numpy
https://stackoverflow.com/questions/64410930/different-results-between-quantized-tflite-model-to-its-implementation-using-num
<p>I am working with Tensorflow/Keras and want to quantize model parameters and then implement the model with Numpy. I've build 1D CNN model ,train it, then quantize its parameters , to UINT8 ,using Tensorflow post training quantization , then i've extract the weights and biases and export it to .npy file. After build ...
1,488
implement quantization
Can libtorch be used for quantization-aware training of models?
https://stackoverflow.com/questions/75886648/can-libtorch-be-used-for-quantization-aware-training-of-models
<p>We want to use C++ to develop a software for deep learning model training and quantification. For the convenience of deployment, we don't want to use python language, so we want to implement it based on libtorch. I found the following example program for python-based quantization-aware training in pytorch's blog.</p...
1,489
implement quantization
Scalar vs Vector signal Quantization
https://stackoverflow.com/questions/70596552/scalar-vs-vector-signal-quantization
<p>I am studying about scalar vs vector quantization, and I have an assignment to implement (in MATLAB) a scalar quantizer , using the Lloyd-Max algorithm, and a vector quantizer via k-means clustering.</p> <p>The <strong>vector</strong> quantizer works in the R<sup>2</sup> vector space, so its input is a tuple of samp...
<p>K-Means is very similar to Lloyd Max algorithm.<br /> Since you give it <code>x2</code> more bits there is no wonders it performs better.</p>
1,490
implement quantization
How pytorch implement forward for a quantized linear layer?
https://stackoverflow.com/questions/72101712/how-pytorch-implement-forward-for-a-quantized-linear-layer
<p>I have a quantized model in pytorch and now I want to extract the parameter of the quantized linear layer and implement the forward manually. I search the source code but only find this function.</p> <pre><code>def forward(self, x: torch.Tensor) -&gt; torch.Tensor: return torch.ops.quantized.linear( x, self....
<p>In answer to the question of where <code>torch.ops.quantized.linear</code> is, I was looking for the same thing but was never able to find it. I believe it's probably somewhere in the <code>aten</code> (C++ namespace). I did, however, find some useful PyTorch-based implementations in the NVIDIA TensorRT repo below. ...
1,491
implement quantization
How to find float output range for quantized matmul/conv2D operation
https://stackoverflow.com/questions/53003155/how-to-find-float-output-range-for-quantized-matmul-conv2d-operation
<p>I am new to tensorflow and quantization, am trying to implement quantized matmul operation for two int8 inputs. Was curious to know the math behind the operation. I see in tensorflow they have implemented the same only for uint8 inputs , would like to know how to use that for signed int8 matmul/conv2D.</p> <p>More ...
<p>I have investigated the quantization in tensorflow a bit and applied it to convert float operations into quant oeprations. </p> <p>In my case I have still a float input to the net. The input gets quantized right before entering the quant operations. Tensorflow prefers keeping float values as long as possible in ord...
1,492
implement quantization
Image Dithering: How would I calculate quantization error and nearest colour to implement in a Floyd-Steinburg algorithm?
https://stackoverflow.com/questions/3867581/image-dithering-how-would-i-calculate-quantization-error-and-nearest-colour-to
<p>I intend to display (4, 8 or 16 bit per channel - no alpha) images on a 1 bit display in an embedded system. Images are stored in RGB tuples. My intention is to use Floyd-Steinburg, as it looks reasonably good, is more than quick enough and concise in code.</p> <p>In reference to the WikiPedia <a href="http://en....
<p>I've seen two typical approaches to measuring the difference between two colors. The most common way is probably to just find the Euclidian distance between them through the color cube:</p> <pre><code>float r = i.r - j.r; float g = i.g - j.g; float b = i.b - j.b; float diff = sqrtf( r * r + g + g + b * b ); </code...
1,493
implement quantization
Issues with MP3-like Compression: Quantization and File Size
https://stackoverflow.com/questions/79333155/issues-with-mp3-like-compression-quantization-and-file-size
<p>I’m trying to implement an MP3-like compression algorithm for audio and have followed the general steps, but I’m encountering a few issues with the quantization step. Here's the overall process I'm following:</p> <ol> <li>Apply Hanning window to the audio</li> <li>Apply a filter bank (mp3_forward_fbt).</li> <li>Appl...
1,494
implement quantization
Color quantization: Same as detecting color palette?
https://stackoverflow.com/questions/53976162/color-quantization-same-as-detecting-color-palette
<p>I'm interested in implementing a tool similar to <a href="https://www.canva.com/color-palette/" rel="nofollow noreferrer">Canva's Palette tool</a>, with the final goal of production CSS UI colors from an image (similar to how Spotify determines UI colors based on album art). </p> <p>I've read about <a href="http://...
<p>There are many ways to find an image's <a href="https://peteroupc.github.io/colorgen.html#Dominant_Colors_of_an_Image" rel="nofollow noreferrer">dominant colors</a>. These include not only octrees but also k-means clustering, histograms, and posterization. Some of them can indeed be used to find an image's color pal...
1,495
implement quantization
Does static quantization enable the model to feed a layer with the output of the previous one, without converting to fp (and back to int)?
https://stackoverflow.com/questions/78026212/does-static-quantization-enable-the-model-to-feed-a-layer-with-the-output-of-the
<p>I was reading about quantization (specifically abount int8) and trying to figure it out if there is a method to avoid dequantize and requantize the output of a node before feeding it to the next one. So i eventually find the definition of static and dynamic quantization. According to <a href="https://onnxruntime.ai/...
<p>Hardware AI guy here, I highly recommend reading my blog, <a href="https://franciscormendes.github.io/2024/05/16/quantization-layer-details/" rel="nofollow noreferrer">https://franciscormendes.github.io/2024/05/16/quantization-layer-details/</a> But I will summarize it here. In short : if you want, you can pass valu...
1,496
implement quantization
Fail to quantize custom layer - Quantization Aware Training
https://stackoverflow.com/questions/70351174/fail-to-quantize-custom-layer-quantization-aware-training
<p>I'm following <a href="https://www.tensorflow.org/model_optimization/guide/quantization/training_comprehensive_guide?hl=en" rel="nofollow noreferrer">Quantization aware training comprehensive guide</a> and struggling with QAT for custom layers, working with <code>tf=2.6.0</code>, <code>py=3.9.7</code>. Below is a to...
1,497
implement quantization
Vector quantization for categorical data
https://stackoverflow.com/questions/27694998/vector-quantization-for-categorical-data
<p>Software for vector quantization usually works only on numerical data. One example of this is Python's <code>scipy.cluster.vq.vq</code> (<a href="http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.cluster.vq.vq.html#scipy.cluster.vq.vq" rel="nofollow">here</a>), which performs vector quantization. Th...
<p>You cannot "quantize" categorial data.</p> <p>Recall <em>definitions</em> of quantization (<a href="https://en.wiktionary.org/wiki/quantize" rel="nofollow">Wiktionary</a>):</p> <blockquote> <ol> <li>To limit the number of possible values of a quantity, or states of a system, by applying the rules of quantum me...
1,498
implement quantization
How to compute Quantization Error for clustering?
https://stackoverflow.com/questions/48178527/how-to-compute-quantization-error-for-clustering
<p>I would like to measure the quality of clustering using Quantization Error but can't find any clear info regarding how to compute this metric.</p> <p>The few documents/ articles I've found are:</p> <ul> <li>"<em><a href="https://www.sciencedirect.com/science/article/pii/S0031320314003781" rel="nofollow noreferrer"...
<p>At the risk of restating things you already know, I'll cover the basics.</p> <p><strong>REVIEW</strong></p> <p><strong>Quantization</strong> is any time we simplify a data set by moving each of the many data points to a convenient (nearest, by some metric) quantum point. These quantum points are a much smaller se...
1,499
implement quantization
How can I do color quantization of images in Android?
https://stackoverflow.com/questions/47287777/how-can-i-do-color-quantization-of-images-in-android
<p>I want to reduce the color count of an image. Android provides a palette library to build palettes: <a href="https://developer.android.com/reference/android/support/v7/graphics/Palette.Builder.html" rel="nofollow noreferrer">https://developer.android.com/reference/android/support/v7/graphics/Palette.Builder.html</a>...
1,500
implement quantization
Set quantize factor in WIC
https://stackoverflow.com/questions/29269431/set-quantize-factor-in-wic
<p>I am trying to Replace the encoder module of a application with my own Encoder which use WIC. and the old one seems set the Quantize factor to 90 (i don't know what happen in there, i just have dlls only). Now i have to set quantize factor too but i don't know how. is there any way to set that value like passing so...
<blockquote> <p>does that affect to the quantization?</p> </blockquote> <p>Yes. </p> <p>that set the quality level and that decide the quintize table which use to compress.</p> <p>normally quality level is considered as a percentage. in WIC it take float value 0-1. </p> <p>if you want to set quality level to 90 (...
1,501
implement quantization
Minimum Variance Quantization and MatLab
https://stackoverflow.com/questions/39842367/minimum-variance-quantization-and-matlab
<p>I've implemented Minimum Variance Quantization algorithm described <a href="https://imcs.dvfu.ru/lib.int/docs/Programming/Graphics/Academic%20Press%20Graphics%20Gems%20Ii%201995.pdf" rel="nofollow noreferrer">here</a> on page 126 (or 154 if you use pdf viewer search). This method is used in matlab function <code>rgb...
1,502
implement quantization
How to convert the model with grid_sample to TensorRT with INT8 quantization?
https://stackoverflow.com/questions/69162186/how-to-convert-the-model-with-grid-sample-to-tensorrt-with-int8-quantization
<p>I am trying to convert the model with torch.nn.functional.grid_sample from Pytorch (1.9) to TensorRT (7) with INT8 quantization throught ONNX (opset 11). Opset 11 does not support grid_sample conversion to ONNX. Thus I used ONNX graphsurgeon together with the external GridSamplePlugin as it is <a href="https://githu...
<p>You can break your model into 2 parts, one before grid sample and another after it, and do int8 quantization respectively. Having grid_sample work in INT8 will compromise your model performance greatly. This will result in a change in your network structure so it may change the optimization of the graph.</p>
1,503
implement quantization
Spatially invariant Vector Quantization
https://stackoverflow.com/questions/13802434/spatially-invariant-vector-quantization
<p>I am trying to implement the <a href="http://www.jpathinformatics.org/article.asp?issn=2153-3539;year=2011;volume=2;issue=1;spage=13;epage=13;aulast=Hipp" rel="nofollow" title="original paper">algorithm</a> by Jason Hipp et al. There is also a <a href="http://www.pathinformatics.pitt.edu/sites/default/files/pathinfo...
<p>Your first two questions are not particular to this algorithm, but any vector quantization algorithm. Here is a web page that describes in relatively easy-to-understand terms how to do vector quantization, including generation of codebooks: <a href="http://www.data-compression.com/vq.html" rel="nofollow">http://www....
1,504
implement quantization
Activations Quantization for Convolutional Neural Network
https://stackoverflow.com/questions/52700676/activations-quantization-for-convolutional-neural-network
<p>I am using Caffe to execute some Convolutional Neural Networks. However, my idea is executing the inference procedure by using quantized activations. Does anybody know the best way to do so? I've been looking up Ristretto, but I am not sure whether that framework quantizes the activations or only the weights. Does a...
1,505
implement quantization
Does C have a Quantization function?
https://stackoverflow.com/questions/1966739/does-c-have-a-quantization-function
<p>I have a buffer with many positive 16bit values (which are stored as doubles) that I would like to quantize to 8bit (0-255 values).</p> <p>According to <a href="http://en.wikipedia.org/wiki/Quantization_%28signal_processing%29#Mathematical_description" rel="nofollow noreferrer">Wikipedia</a> the process would be:</...
<p>Assuming the value <code>d</code> is in the interval <code>[0.0, max]</code>:</p> <pre><code>unsigned char quantize(double d, double max) { return (unsigned char)((d / max) * 255.0); } </code></pre> <p>I'm not sure what you mean by "16-bit values;" double precision values are 64-bit on any system using IEEE-75...
1,506
implement quantization
Is there a differentiable algorithm for image quantization?
https://stackoverflow.com/questions/74142324/is-there-a-differentiable-algorithm-for-image-quantization
<p>I am implementing an autoencoder, used to rebuild color images. The loss function I want to use requires a reduced color set (max ~100 different colors) but I am struggling to find a suitable differentiable algorithm.</p> <p>Another doubt I have is the following: is it better to apply such quantization directly in t...
<p>If you want to compress <strong>the image</strong>, it seems you want to find discrete color set for image compression. In that case auto-encoder is not suitable approach for image compression.</p> <p>The general auto-encoder compress tensor of images(<code>B x C x H x W</code>) to latent code of each images(<code>B...
1,507
implement quantization
TFLiteConverter parameters for optmization on TensorFlow 1.x
https://stackoverflow.com/questions/60998416/tfliteconverter-parameters-for-optmization-on-tensorflow-1-x
<p>I've been learning about quantization on TensorFlow 2.x using TFLiteConverter, however I'm implementing a project on TensorFlow 1.13 and I'd like to know how to do the same things on this version.</p> <p>For example, as far as I've observed the following commands do the same thing</p> <pre><code># tf 1.x converter...
<p>AFAIK, the following two are equivalent.</p> <pre><code># tf 1.x converter.post_training_quantize = True # tf 2.x converter.optimizations = [tf.lite.Optimize.DEFAULT] </code></pre> <p><code>converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]</code> is used for full integer quantization. </p> <p>Please...
1,508
implement quantization
Algorithm for color quantization/reduced image color palette in JavaScript?
https://stackoverflow.com/questions/6205955/algorithm-for-color-quantization-reduced-image-color-palette-in-javascript
<p>I'm writing a web app that takes a user-submitted image, gets the pixel data via a <code>canvas</code> element, does some processing, and then renders the image using vector shapes (using <a href="http://vis.stanford.edu/protovis/" rel="nofollow noreferrer">Protovis</a>). It's working well, but I end up with several...
<p>With the caveat that I don't claim any expertise at all in any field of image processing: I read over the Wikipedia article you linked, and from there found Dan Bloomberg's <a href="http://www.leptonica.com">Leptonica</a>. From there you can <a href="http://www.leptonica.com/download.html">download</a> the sources ...
1,509
implement quantization
&quot;NotImplementedError: Could not run &#39;aten::add.out&#39; with arguments from the &#39;QuantizedCPU&#39; backend&quot; while implementing QAT on resnet18 using pytorch
https://stackoverflow.com/questions/79240688/notimplementederror-could-not-run-atenadd-out-with-arguments-from-the-qua
<p>I am trying to implement Quantization Aware Training(QAT) resnet18 model. While inferring I get this error</p> <pre><code>NotImplementedError: Could not run 'aten::add.out' with arguments from the 'QuantizedCPU' backend </code></pre> <p>I am trying to follow <a href="https://pytorch.org/docs/stable/quantization.html...
<p>This tutorial tells that for torch 2.0 this feature is beta and you need to adjust original model with at least one change (<a href="https://pytorch.org/tutorials/advanced/static_quantization_tutorial.html#model-architecture" rel="nofollow noreferrer">https://pytorch.org/tutorials/advanced/static_quantization_tutori...
1,510
implement quantization
How to manually dequantize the output of a layer and requantize it for the next layer in Pytorch?
https://stackoverflow.com/questions/78239906/how-to-manually-dequantize-the-output-of-a-layer-and-requantize-it-for-the-next
<p>I am working on school project that requires me to perform manual quantization of each layer of a model. Specifically, I want to implement manually:</p> <blockquote> <p>Quantized activation, combined with quantized weight A - layer A - quantized output - dequantized output - requantized output, combined with quantiz...
<p>Fundamentally you are looking at converting the matrix multiplication :</p> <p>$$Y = WX+b$$</p> <p>De quantization is carried out according to this formula : Where $S_i, Z_i$ are the scale and zero point of the $X$ (activations in your case) and bias, $b$.</p> <p>$$Y = S_xS_w(X_q-Z_x)(W_q-Z_w) + S_b(b_q-Z_b)$$</p> <...
1,511
implement quantization
Faster implementation to quantize an image with an existing palette?
https://stackoverflow.com/questions/50801935/faster-implementation-to-quantize-an-image-with-an-existing-palette
<p>I am using Python 3.6 to perform basic image manipulation through Pillow. Currently, I am attempting to take 32-bit PNG images (RGBA) of arbitrary color compositions and sizes and quantize them to a known palette of 16 colors. Optimally, this quantization method should be able to leave fully transparent (A = 0) pixe...
<p><code>for</code> loops should be avoided for speed.</p> <p>I think you should make a tensor like:</p> <pre><code>d2[x,y,color_index,rgb] = distance_squared </code></pre> <p>where rgb = 0..2 (0 = r, 1 = g, 2 = b).</p> <p>Then compute the distance:</p> <pre><code>d[x,y,color_index] = sqrt(sum(rgb,d2)) </code></...
1,512
implement quantization
Stable Diffusion v1.4 PTQ on both weight and activation
https://stackoverflow.com/questions/79555026/stable-diffusion-v1-4-ptq-on-both-weight-and-activation
<p>I'm currently working on quantizing the Stable Diffusion v1.4 checkpoint without relying on external libraries such as torch.quantization or other quantization toolkits. I’m exploring two scenarios:</p> <p>Dynamic Quantization: I store weights in INT8 but dequantize them during inference. This approach works as expe...
1,513
implement quantization
how to perform color quantization in matlab or otherwise
https://stackoverflow.com/questions/10372681/how-to-perform-color-quantization-in-matlab-or-otherwise
<p>I am implementing a machine learning algorithm in matlab, and was doing some reading up on the color range of the human eye, and was informed that the human eye can only perceive about 17,000 colors, where as the images I have about 256^3 colours. What is the best way to quantization my images, in matlab or otherwis...
<p>JPEG is a lossy format. You should not use it if your input data is not already JPEG. Even if so, you should not re-compress your data to avoid introduction of further artifacts.</p> <p>A very simple, yet popular method for color quantization is the k-means algorithm. You can find it in Matlab. This is a good start...
1,514
implement quantization
NeuQuant.js (JavaScript color quantization) hidden bug in JS conversion
https://stackoverflow.com/questions/16371712/neuquant-js-javascript-color-quantization-hidden-bug-in-js-conversion
<p><a href="https://github.com/antimatter15/jsgif/blob/master/NeuQuant.js" rel="nofollow noreferrer">NeuQuant.js</a> works well when the image width and height are a multiple of 100:</p> <p><img src="https://i.sstatic.net/uiWXI.gif" alt="300x300 animated gif"> 300x300</p> <p>Otherwise, there is obviously a bug:</p> ...
<p>JavaScript code seems to ignore that C truncates the results of the operations with decimal numbers before assign them to integer variables. So, <code>int i = 5 / 2;</code> is <code>2</code> to C, but <code>var i = 5 / 2;</code> is <code>2.5</code> to JavaScript.</p> <p>Said that, change this line:</p> <pre><code>...
1,515
implement quantization
Is Elu int8 quantisation working on Tensorflow Lite?
https://stackoverflow.com/questions/67774808/is-elu-int8-quantisation-working-on-tensorflow-lite
<p><em>Context</em> :<br /> I would like to run inferencing of a DL-model on an Arduino and, since I don't have much memory available, I need to post-training <strong>int8-quantize</strong> my model.<br /> But the <strong>quantization</strong> of my model <strong>doesn't seem to be working</strong>, and it seems to be ...
1,516
implement quantization
torch Parameter grad return none
https://stackoverflow.com/questions/74387343/torch-parameter-grad-return-none
<p>I want to implement learned size quantization algorithm. And I create a quante Linear layer</p> <pre class="lang-py prettyprint-override"><code>class QLinear(nn.Module): def __init__(self, input_dim, out_dim, bits=8): super(QLinear, self).__init__() # create a tensor requires_grad=True se...
<p>The issue is that you are passing <code>dequant_weight</code> through data attribute of your parameter which ends up not being registered by autograd. A simple alternative would be to handle <code>weight</code> as a <a href="https://pytorch.org/docs/stable/generated/torch.nn.parameter.Parameter.html" rel="nofollow n...
1,517
implement quantization
How to remove &quot;infinite&quot; while loop to improve MATLAB code?
https://stackoverflow.com/questions/66075396/how-to-remove-infinite-while-loop-to-improve-matlab-code
<p>I am implementing a logarithmic quantizer and what I would like to do is to optimize the code as much as possible. The precise point where I would like to make a change is the last <code>else</code> statement where the equation to be implemented is:</p> <p><code>q(u) = u_i</code> if <code>u_i/(1+step) &lt; u &lt;= u...
<p>Assuming <code>u_min&gt;0</code> and <code>0&lt;p&lt;1</code>, you can simplify <code>(u &gt; u_i/(1+step)) &amp;&amp; (u &lt;= u_i/(1-step))</code> to:</p> <pre><code>u/u_min &gt; p^(1-i) &amp;&amp; p^-i &gt;= u/u_min </code></pre> <p>Which since <code>log</code> is monotonic, simplifies to</p> <pre><code>-log(u/u_...
1,518
implement quantization
What is the condition to stop splitting data in Non-Uniform Quantizer?
https://stackoverflow.com/questions/41026017/what-is-the-condition-to-stop-splitting-data-in-non-uniform-quantizer
<p>I'm trying to implement a non-uniform quantizer with N-level of quantization. I have already done some work and it works, the problem is it goes into infinite loop when N(the number of levels) exceeds "4".</p> <p>If anyone can point out any hints to know where the wrong is, I'd appreciate it.</p> <pre><code>public...
1,519
implement quantization
Is there an implementation of libjpeg in python?
https://stackoverflow.com/questions/9695896/is-there-an-implementation-of-libjpeg-in-python
<p>I am writing some python code that needs <a href="http://www.ijg.org/" rel="nofollow">libjpeg</a> . I searched for it on the Internet, and I couldn't find an implement of libjpeg in python. I would like to be able to access, DCT coefficient values, quantization tables, etc.</p> <p>Thanks!</p>
<p>That would be the <a href="http://docs.python.org/library/jpeg.html" rel="nofollow"><code>jpeg</code></a> module. However, typically the <a href="http://www.pythonware.com/products/pil/" rel="nofollow">Python Imaging Library</a> is preferred for image manipulation.</p>
1,520
implement quantization
Is it possible to configure TFLite to return a model with bias quantized to int8?
https://stackoverflow.com/questions/63303255/is-it-possible-to-configure-tflite-to-return-a-model-with-bias-quantized-to-int8
<p>I'm working with Keras/Tensorflow to develop an ANN that will be deployed to a low-end MCU. For this purpose, I have quantized the original ANN using the post-training quantization mechanism offered by Tensorflow Lite. If the weights are indeed quantized to int8, biases were converted from float to int32. Considerin...
<p>From Comments</p> <blockquote> <p>It's not possible to configure <code>TFLite</code> to do that. <code>Biases</code> are intentionally <code>int32 </code>otherwise the quantization accuracy would not be good. In order to make this work, you'd have to add a new op or custom op and then come up with a custom quantizat...
1,521
implement quantization
How to create if else statement in a custom Keras layer
https://stackoverflow.com/questions/73369209/how-to-create-if-else-statement-in-a-custom-keras-layer
<p>I am trying to define a custom layer in Keras, where the data values are first quantized as -1, 0, or 1. Then, every -1 is transformed to 0. For example, The input tensor is x = [-0.95, -0.85,0.1,0.9]. It will be quantized to x1 = [-1,-1,0,1]. Then, x2 is transformed to x3 = [0,0,0,1]. I have completed the quantizat...
1,522
implement quantization
How to implement TF Lite inference in Python
https://stackoverflow.com/questions/61850203/how-to-implement-tf-lite-inference-in-python
<p>For research purposes, I'm trying to understand how TF Lite does its inference. I'm interested only in the software logic.</p> <p>I'm using TensorFlow 2.1 and TensorFlow Model Optimization 0.3.0.</p> <p>As an example, I use a very simple fully connected network:</p> <pre><code>tf.keras.models.Sequential([ tf....
<p>At last, I solved this issues by digging into TensorFlow/Lite code. I found the relevant code and modified it, so it printed all the relevant info that I needed into text files. From there I could parse everything in Python and run a Pythonic version of the cpp logic.</p> <p>In case someone will want to try and do ...
1,523
implement quantization
Wildly different quantization performance on tensorflow-lite conversion of keras-trained DenseNet models
https://stackoverflow.com/questions/53050923/wildly-different-quantization-performance-on-tensorflow-lite-conversion-of-keras
<p>I have two models that I have trained using Keras. The two models use the same architecture (the DenseNet169 implementation from <code>keras_applications.densenet</code> package), however they each have a different number of target classes (80 in one case, 200 in the other case).</p> <ul> <li><p>Converting both mod...
<p><em>This was intended to be just a small sneaky comment since i'm not sure if this can help, but then it got so long that I decided to make it an answer...</em></p> <hr> <p><strong>My wild guess</strong> is that the accuracy drop may be caused by the variance of the output of your network. After quantization (btw,...
1,524
implement quantization
OpenGL triangle degeneration after vertex shader?
https://stackoverflow.com/questions/37069477/opengl-triangle-degeneration-after-vertex-shader
<p>Referring to that <a href="https://stackoverflow.com/questions/34422774/opengl-degenerate-gl-triangles-sharing-same-vertices/">question</a>:</p> <p>There are several ways to improve rendering speed for huge meshes. I tried the following implementations:</p> <ol> <li>Just render the mesh without any optimization or...
<p>I hate to bring up the obvious, but have you tried resizing your framebuffer to something absurd like 1x1 and confirming that the bottleneck is in-fact vertex processing?</p> <p>Given no screenshot or anything to go by, I have to guess what the "huge" mesh you are trying to render looks like; I can think of a lot o...
1,525
implement quantization
Layer up_sampling2d:&lt;class &#39;tensorflow.python.keras.layers.convolutional.UpSampling2D&#39;&gt; is not supported
https://stackoverflow.com/questions/61406595/layer-up-sampling2dclass-tensorflow-python-keras-layers-convolutional-upsampl
<p>I am trying to implement UNet for Semantic Segmentation that can run on Google Coral edgetpu. In order to do so, we need to have a quantized model that can be obtained using the tensorflow_model_optimization API.</p> <p>But while using the API, there is a layer for UpSampling2D which is not supported by the <a href...
1,526
implement quantization
How to reduce the number of colors in an image with OpenCV?
https://stackoverflow.com/questions/5906693/how-to-reduce-the-number-of-colors-in-an-image-with-opencv
<p>I have a set of image files, and I want to reduce the number of colors of them to 64. How can I do this with OpenCV?</p> <p>I need this so I can work with a 64-sized image histogram. I'm implementing CBIR techniques</p> <p>What I want is color quantization to a 4-bit palette.</p>
<p>There are many ways to do it. The methods suggested by jeff7 are OK, but some drawbacks are:</p> <ul> <li>method 1 have parameters N and M, that you must choose, and you must also convert it to another colorspace.</li> <li>method 2 answered can be very slow, since you should compute a 16.7 Milion bins histogram and...
1,527
implement quantization
What is training and testing in image processing?
https://stackoverflow.com/questions/34577701/what-is-training-and-testing-in-image-processing
<p>I'm implementing color quantization based on <em>k-means clustering</em> method on some RGB images. Then, I will determine the performance the algorithm. I found some information about training and testing. As I understand, I should divide the samples of images for training and testing. </p> <p>But I am confused a...
<p>Training and testing are two common concepts in <em>machine learning</em>. Training and testing are more easily explained in the framework of <em>supervised learning</em>; where you have a training dataset for which you know both input data as well as additional attributes that you want to predict. Training consists...
1,528
implement quantization
Display dark 16-bit .tiff in Canvas
https://stackoverflow.com/questions/35711632/display-dark-16-bit-tiff-in-canvas
<p>I'm trying to display a 16-bit tiff image in a html5 canvas, I found this library <a href="https://github.com/seikichi/tiff.js/" rel="nofollow">seikichi/tiff.js</a> and it works well but my images are dark, the pixel values are in the range [0- 300] then the image is quantized badly, the canvas displays a black imag...
1,529
implement quantization
2-DCT Image compression matlab
https://stackoverflow.com/questions/53006940/2-dct-image-compression-matlab
<p><strong>Problem:</strong></p> <p>I tried implementing Discrete Cosine Transformation compression using matlab. Input image would a jpg image (Lena) having a size 512 X 512.</p> <p>There are two stages namely compression and decompression. </p> <p><strong>Compression and Quantization:</strong></p> <p>The input im...
1,530
implement quantization
Error while training pruned and quantized CNN model using TensorFlow Model Optimization
https://stackoverflow.com/questions/79052285/error-while-training-pruned-and-quantized-cnn-model-using-tensorflow-model-optim
<p>I'm working on a deep learning project where I'm trying to implement a convolutional neural network (CNN) for Human Activity Recognition (HAR) using time-series data. The pipeline involves training a VGG-like teacher model, pruning it for efficiency, applying quantization-aware training, and then distilling the know...
1,531
implement quantization
I am trying to implement jpeg compression using FFT2 instead of DCT2 in Matlab and export binary files to be decoded
https://stackoverflow.com/questions/75939516/i-am-trying-to-implement-jpeg-compression-using-fft2-instead-of-dct2-in-matlab-a
<p>As per the title, I am having more trouble trying to convert to binary file. Below are my steps.</p> <p><strong>JPEG Compression Steps</strong></p> <ol> <li>Convert RGB into 3 channels</li> <li>For each channel (Y,Cb,Cr)</li> </ol> <ul> <li><p>(2.1) If channel is Cb or Cr</p> <ul> <li>Downsample</li> </ul> </li> <li...
1,532
implement quantization
Unexpected memory usage when training transformer models with LoRA and quantization
https://stackoverflow.com/questions/78895910/unexpected-memory-usage-when-training-transformer-models-with-lora-and-quantizat
<p>I am training models using transformers, accelerate, bitsandbytes and PEFT. I recently got a second graphics card (RTX 3090) and am seeing a decent increase in training speed. However when experimenting with Lora and quantization, I found certain combinations weren't reducing memory as I'd expect.</p> <p>If I unders...
1,533