Context-AwAre Retrieval of Trademark Publications Using Natural Language Querying Systems
Advisor: Ms. Vibha
Internship Location: Remote work at Huski.ai
Onsite Mentor: Michael Oliver
Generative AI often depends on outdated or incomplete information, which Can lead to false or misleading outputs—What experts call “AI hallucinations.” That might not matter much if you’re just looking for a new dinner recipe, but it’s a serious issue when dealing with patents, where every detail Can influence legal and business decisions. My project tackles this by building a “retrieval-augmented generation” (RAG) system that draws on the United States Patent and Trademark Office (USPTO) database in real time, ensuring the AI Can pull up the latest, most relevant data before generating an answer. This approach is vital because inventors, startups, and legal professionals rely on accurate, up-to-date patent information to avoid costly errors—whether they’re creating a new product, shaping a business strategy, or protecting their intellectual property. By pairing a state-of-the-art language model with real-time retrieval, my system aims to minimize these “hallucinations” while saving countless hours of manual searching, ultimately making patent insights more accessible, trustworthy, and empowering for anyone who depends on informed, rapid decision-making in today’s fast-paced world.
Project Blog
Post 1: Blog 0
Hi everyone! My name is Arush, and welcome to my first Senior Project blog post! Here, I’ll introduce my project, explain why I’m tackling AI’s reliability issues in patent research, and outline what I’ll be doing over the next few months.
We’ve all seen how AI can generate text, summarize articles, and even help with coding. But there’s a catch: AI sometimes makes things up, a phenomenon known as “AI hallucination.” In most cases, this isn’t a big deal. But when it comes to patents, where every detail can determine whether an invention is legally protected, misinformation can have serious financial and legal consequences.
Patent research is an essential but time-consuming process. Whether it’s a startup ensuring their new product doesn’t infringe on existing patents, an inventor looking to protect their intellectual property, or a law firm building a case, having accurate and up-to-date patent data is crucial. However, current generative AI models do not have direct access to real-time, authoritative patent data, leading to incomplete or inaccurate results that could mislead users.
That’s where my project comes in. I’m developing a Retrieval-Augmented Generation (RAG) system that integrates a large language model (LLM) with the United States Patent and Trademark Office (USPTO) database. Instead of relying on outdated training data, my system will retrieve and incorporate the latest, most relevant information before generating a response. This approach will significantly reduce misinformation and make AI a more reliable tool for patent professionals.
So What Will I Be Doing?
My project involves several key steps:
Data Processing – Structuring the USPTO database so the AI can efficiently retrieve relevant patents.
System Development – Building a retrieval mechanism that enables real-time data access.
Model Optimization – Fine-tuning the LLM to ensure it prioritizes accuracy and relevance in patent-related queries.
Testing & Evaluation – Running accuracy tests to ensure the AI delivers reliable responses and minimizes hallucinations.
Why Does This Matter? AI has the potential to revolutionize how we interact with information, but its reliability needs improvement especially in fields where accuracy is non-negotiable. By making AI-powered patent research more dependable, my project aims to save time, reduce legal risks, and improve decision-making for those working with intellectual property.
Over the next few months, I’ll be documenting my progress, discussing challenges, and sharing insights as I work on building this system. If you’re interested in AI, patents, or just want to see what happens when technology meets legal complexity, stay tuned!
Thanks for reading, and as always peace out girl scouts.
Arush Joshi
Week 1
This week marked the official start of my senior project, and I spent the first few days deepening my understanding of Retrieval-Augmented Generation (RAG) and its role in improving AI-driven patent research. While I had a solid grasp of the concept from my initial research, diving into academic papers and real-world implementations gave me a clearer picture of the strengths and limitations of RAG models in high-stakes fields like law and intellectual property.
One of my biggest takeaways was the extent to which AI hallucinations or confidently incorrect responses pose a challenge in legal and technical searches. Unlike casual chatbot applications, where minor inaccuracies are acceptable, misinformation in patent research can have serious consequences, from legal risks to failed investments. This reinforced the importance of real-time retrieval in ensuring accuracy. I also analyzed existing AI-powered patent search tools, noting that many rely on outdated keyword-based approaches rather than contextual retrieval. This gap presents an exciting opportunity for my project.
In addition to literature review, I began exploring the USPTO patent database and its API documentation. Understanding how patent data is structured is a crucial first step in designing an effective retrieval system. I documented key insights and identified datasets that will be useful in later phases.
Looking ahead, I’ll be finalizing my methodology and beginning the initial steps of dataset preprocessing. Week 1 was all about laying the groundwork, and I’m excited to start turning research into implementation in the coming weeks!
Week 2: Blog
In Week 2, my primary goal was to become deeply familiar with the USPTO patent database and plan the initial architecture for my retrieval system. At first, navigating the complexity of the USPTO database felt overwhelming, with its detailed API documentation and layered data structures. However, after spending some focused time dissecting the documentation, I started identifying clear paths to integrate this information into my Retrieval-Augmented Generation (RAG) system.
One of the key accomplishments this week was finalizing my methodology for real-time retrieval integration. I decided on a strategy that involves vectorizing patent data to enable semantic searches, aiming to significantly reduce inaccuracies or “hallucinations” from the generative AI model. This decision wasn’t easy. I considered various methods and weighed their effectiveness carefully before selecting semantic search as my best solution.
Additionally, I began developing initial system architecture plans. Sketching diagrams and mapping out interactions between components like data retrieval, AI integration, and user interfaces helped clarify the project’s next steps. By the end of the week, the project felt much more tangible and achievable.
Looking forward, I’m ready to dive into data preprocessing and initial testing. The groundwork laid this week has set the stage nicely for the coming challenges.
Post 4: Diving into Data Processing and Embedding Techniques-Blog 3
Diving into Data Processing and Embedding Techniques
In Week 3, I transitioned from planning to action, focusing primarily on data processing and preparing the USPTO patent data for efficient retrieval. The main task was vectorizing large datasets—a critical step for enabling semantic search. Initially, handling and converting such extensive data into usable embeddings posed challenges, including managing computational resources effectively and ensuring accurate representation of patent terminology.
To tackle this, I experimented with different embedding methods, such as Sentence-BERT and Word2Vec, to determine which provided the most meaningful vector representations for complex legal and technical language. After careful comparison, I settled on Sentence-BERT due to its superior ability to capture semantic nuances essential for accurate patent searches.
This week wasn't without technical hurdles—managing the scale of the data and maintaining processing efficiency required fine-tuning my approach, including exploring strategies for data batching and parallel processing. Documenting these steps clearly has given me valuable insights into optimizing future stages of system development.
Looking ahead, next week's goal is to implement the first iteration of the retrieval system, bringing me closer to seeing real-time AI-powered patent searches in action.
Post 5: Blog 4
This week marked an exciting step in my project journey: implementing the initial version of the retrieval system that interacts directly with the USPTO database. My main goal was straightforward—set up the system so it could efficiently retrieve relevant patent information to eventually integrate with my AI model. However, this turned out to be far more complicated than anticipated.
Initially, I worked on downloading and preparing the USPTO dataset, successfully vectorizing patent data using a Sentence Transformer model and setting up a FAISS index for quick similarity searches. Seeing the vectorized data load smoothly into the FAISS index felt like a significant win, giving me a solid foundation for future development.
However, my momentum slowed significantly when I encountered major hurdles accessing the USPTO API. Despite thoroughly reviewing the documentation, I frequently ran into authentication errors and rate-limiting issues. Hours of troubleshooting and experimenting with various API endpoints yielded slow progress, leading me to temporarily shift gears to manually downloaded data.
Additionally, attempting to locally run the latest version of the Llama model on my laptop proved challenging due to hardware limitations. I experienced multiple crashes and memory overloads, which meant I spent considerable time exploring optimization techniques like quantization to reduce memory usage. While these solutions partially alleviated the issues, running the model reliably remained difficult, and I'll likely need to explore cloud-based solutions moving forward.
Despite the frustrations, these challenges taught me valuable lessons in adaptability and resource management. I now appreciate the importance of thorough testing and incremental development when working with resource-intensive AI models. Next week, I'll focus on refining database queries and exploring more stable options for hosting the AI model to continue making steady progress.
Post 6: Blog 5
This week marked a shift in direction for my project. While I had initially been working with XML files and trying to parse full patent datasets, I discovered that the USPTO's Official Gazette offers a much more accessible and structured format. Each weekly Gazette contains the core information I need—titles, inventor names, descriptions, and even images—presented cleanly in HTML.
This was a breakthrough, but it also meant taking a step back. Much of the work I had done to prepare for parsing XML will now need to be reworked to handle HTML instead. It’s not wasted effort, but it does slow things down temporarily while I adjust the pipeline. I'll need to rewrite parts of my code, reconsider how I store and extract data, and find a new way to associate images with the text content.
Despite the detour, I think this is the right call. The Gazette files are smaller, easier to parse, and give me a clearer path toward a working RAG demo. My plan for next week is to build a parser that can extract the text and images from the Gazette and format them for embedding. With that in place, I’ll be back on track and much closer to delivering something usable.
Week 6
This week, I made a breakthrough in understanding the structure of the USPTO Gazette files. After digging through dozens of directories and HTML indexes, I finally located the actual data entries that contain the full information I need. Inside the html/ folder, I found that each granted patent has its own individual HTML file that includes the title, description, inventor names, classification codes, and more. Even better, each file is paired with a .gif image showing the drawing or figure associated with the patent.
This was a major moment of clarity. Up until now, I had been navigating various navigation pages and framesets that seemed empty or incomplete. But now that I’ve found the raw content, I can confidently move forward with writing my parser. The next step will be extracting relevant fields from these HTML files using BeautifulSoup and matching them with their corresponding images. From there, I can begin preparing the content for embedding and search.
Although it took more time than I expected, this week was a turning point in getting a complete dataset that’s both rich and lightweight. I feel back on track, and I’m excited to finally start building the backend of my RAG pipeline.
Post 8: Blog 7
This week, I finally transitioned from preparation to execution. After identifying the correct structure of the USPTO Gazette files last week, I coded a custom parser that can extract all key information from each patent HTML file. This includes the title, inventor names, classification codes, and—most importantly—the full description text. I applied this parser to Gazette issues going all the way back to 2020, giving me a rich and diverse dataset.
Once extracted, I embedded the textual content using a SentenceTransformer model and stored the resulting vectors in a FAISS database. This step is at the heart of the Retrieval-Augmented Generation (RAG) pipeline: transforming patent data into a searchable vector space that enables natural language queries. The FAISS index is now fully populated and ready to power context-aware retrieval.
One area I'm still working on is embedding the patent images. While each HTML file links to a corresponding .gif image, I'm exploring the best approach to turn these images into embeddings—likely using a model like CLIP. This step is trickier due to image formatting and memory requirements, but I'm confident I can solve it next week.
Overall, this was a major leap forward. I now have a working, text-based RAG backend with over four years of real-world patent data.
Post 9: Blog 8
This week, I completed a major milestone for my RAG project by embedding the full patent text and image data from 2020 to 2025. I parsed all gazette files year by year, organized the data into structured CSV files, and embedded the text descriptions into FAISS indexes using Sentence Transformers. Each year now has its own separate FAISS index and metadata file, keeping the data modular and searchable.
On the image side, I initially faced challenges embedding the drawings due to performance bottlenecks with the slow CLIP image processor. After resolving dependency issues and installing Torchvision, I upgraded to the fast CLIP processor, which significantly improved embedding speed. I also leveraged batching and utilized my M3 Pro’s MPS (Metal Performance Shaders) hardware acceleration to process a large volume of images efficiently.
In total, I processed and embedded approximately 97,000+ images, creating a separate set of image embeddings and metadata files. Now, both text and image embeddings are complete for all six years, ready to be integrated into the final RAG pipeline. Next week, I plan to work on the retrieval and generation components to demonstrate full end-to-end functionality.
Post 10: Blog 9
This week, I focused on connecting the final stage of my RAG pipeline: integrating the OpenAI API to handle the user query and generate refined search prompts. The goal was to take a user’s natural question, pass it to the API to rephrase or enhance it into a more structured query, and then use that version to search my FAISS vector database.
I wrote code that takes the user’s input, sends it to OpenAI’s model via API, and receives a more targeted query in return. This query is then converted into an embedding using the same sentence-transformer model I used earlier. The embedding is searched against the FAISS index (2020–2025), and the closest matching patents are returned.
This step was critical because it brings the system together: human input, AI-enhanced querying, and accurate retrieval. Next week, I’ll begin working on formatting and presenting the results in a clear way potentially through a small API or front-end interface. This part really demonstrated how powerful the combination of LLMs and vector databases can be for real-world search systems.
Week 10: Blog: Final Showcase and Reflections
Week 10 Blog: Final Showcase and Reflections
This final week was about wrapping everything up. I focused on getting the Gradio interface fully polished, ensuring that users could search for patents using either text or an image. The final interface displays a clean Markdown table with key metadata, GIF previews, and a summary generated by an LLM. One of the biggest improvements was allowing users to enter a Patent Number and preview the full HTML front page, including embedded images. This resolved previous issues with broken links and gave the app a professional, complete feel.
The debugging process this week was particularly important. I faced some tricky issues with image previews not loading and Gradio’s server security restrictions, but found workarounds like base64-embedding images directly in the HTML. I also made sure the final output met every requirement listed in my syllabus.
Overall, I’m proud of the way everything came together. The project is now stable, interactive, and ready to showcase.