Skip to content

Commit

Permalink
feat(docs): new blog post announcing Q&A and semantic search
Browse files Browse the repository at this point in the history
  • Loading branch information
cfu288 committed Feb 1, 2024
1 parent 9428a42 commit f69b56f
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 22 deletions.
6 changes: 1 addition & 5 deletions apps/docs/blog/2023-01-07-what-is-mere-medical.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
slug: what-is-mere-medical
title: What is Mere Medical?
authors:
name: Christopher Fu
title: Developer of Mere Medical
url: https://cfu288.com
image_url: https://files.meremedical.co/profile.jpg
authors: [cfu288]
---

About a year ago, I was a second-year medical student preparing to start my third-year clinical rotations. It was a pretty exciting but terrifying time - I was also getting ready to take my first set of board exams. On top of long days of studying, I had to complete a lot of paperwork required by the school and the hospitals I would be rotating at. One of the biggest things I needed to get done before starting my rotations was ensuring I was up to date on my vaccinations and had my latest health records.
Expand Down
6 changes: 1 addition & 5 deletions apps/docs/blog/2023-03-07-customize-mere-with-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
slug: exploring-extensibility-with-cds-hooks
title: Personalizing Your Personal Health Record with Plugins
description: A proposal to supercharge your personal health record with third-party CDS hooks
authors:
name: Christopher Fu
title: Developer of Mere Medical
url: https://cfu288.com
image_url: https://files.meremedical.co/profile.jpg
authors: [cfu288]
---

Personal health records (PHRs) such as Mere do a great job of syncing and showing you your medical records across different healthcare providers. Mere makes it easy to read and search for your medical records across multiple health systems. Want to compare your last red blood cell count to your previous lab results? Mere will generate a graph for you. Need help remembering which vaccines you've already gotten? Mere can group and summarize your entire vaccine history in one view.
Expand Down
6 changes: 1 addition & 5 deletions apps/docs/blog/2023-03-17-customize-mere-with-plugins-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
slug: exploring-extensibility-with-cds-hooks-part-2
title: Digging Deeper into CDS Hooks for Personal Health Records
description: A proposal to supercharge your personal health record with third-party CDS hooks
authors:
name: Christopher Fu
title: Developer of Mere Medical
url: https://cfu288.com
image_url: https://files.meremedical.co/profile.jpg
authors: [cfu288]
toc_min_heading_level: 2
toc_max_heading_level: 5
hide_table_of_contents: false
Expand Down
82 changes: 82 additions & 0 deletions apps/docs/blog/2024-01-23-ai-in-mere.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
slug: adding-ai-semantic-search-and-qa-to-mere
title: Adding AI Semantic Search and Q&A to Mere
description: Implementing RAG and Semantic Search using OpenAI Embeddings and GPT-4-Turbo
authors: [cfu288]
toc_min_heading_level: 2
toc_max_heading_level: 5
hide_table_of_contents: false
---

## Why Semantic Search?

A year ago, during a feedback session, an early Mere user reported a "broken" search bar. She had entered "diabetes" and "high blood sugar" into the Mere search bar but received no results. While Mere's search _was_ functioning correctly, performing basic text queries, it failed to meet her expectations of recognizing the relationship between her search terms and related medical records like A1c and blood glucose levels. This incident highlighted the need for a more sophisticated, semantic search capability.

<!--truncate-->

### What is Semantic Search?

Semantic search is a search technique that uses semantics, or the science of meaning in language, to understand the intent of a user's search query. It goes beyond the traditional keyword-based approach to consider the context and meaning of the query. This allows the search engine to return more relevant results, even if the search terms are not an exact match to the content.

An example of semantic search is when a user searches for "high blood sugar," the search engine understands that the user is also interested in records containing "diabetes" and "A1c" and returns these records as well.

### Bringing Semantic Search to Mere using OpenAI Embeddings

As of today, users now have the option to activate semantic search within the experimental settings of Mere. This feature employs OpenAI's `text-embedding-3-large` model to create embeddings for user records. During a search, Mere leverages these embeddings to identify and retrieve the most relevant records based on the search query.

Below is a quick demo of the difference between the existing simple text search and the new semantic search in Mere.

<div className="flex-col sm:flex-row flex w-full gap-1">
<div className="">
<p>With the Old Text Search:</p>
<video width="100%" height="auto" controls>
<source src="/vid/ExactSearch.mp4" type="video/mp4" alt="Exact search demo"/>
Your browser does not support the video tag.
</video>
</div>
<div>
<p>With the New Semantic Search:</p>
<video width="100%" height="auto" controls>
<source src="/vid/SemanticSearch.mp4" type="video/mp4" alt="Semantic search demo"/>
Your browser does not support the video tag.
</video>
</div>
</div>
<br/>

As you can see, the semantic search is able to return relevant results to the user that the previous simple text search could not.
<br/>

# Building Q&A into Mere using Semantic Search and RAG (Retrieval-Augmented Generation)

Mere aims to do more than just display your data; it's here to help you understand it. Now, if you're puzzled by a lab result, simply ask your question through the new Q&A feature by clicking on the Mere AI Assistant tab.

Here's a video of the Q&A feature in action:

<div className="flex w-full p-2">
<video width="100%" height="auto" controls>
<source src="/vid/DoIHaveAnemiaDemo.mp4" type="video/mp4" alt="Q&A demo"/>
Your browser does not support the video tag.
</video>
</div>
<br/>

The Mere AI Assistant utilizes OpenAI's `gpt-4-turbo` for generating answers to user inquiries. Upon receiving a question, Mere employs semantic search to locate the most pertinent records related to the query, forwards this data along with the question, and uses `gpt-4-turbo` to produce a response.

<br/>

## Want to try it out?

:::warning

Activating these features means your records **will be transmitted to OpenAI** for processing. If this raises privacy concerns for you, it is advisable not to enable these features.

:::

The semantic search and Q&A functionalities are situated within the experimental segment of the settings tab. By default, experimental features are not visible; to view them, select _Show experimental features_.

To activate semantic search and Q&A, navigate to the settings tab, proceed to the experimental segment, and toggle on the desired features. Please be aware that activation requires you to acquire and enter [your own OpenAI API key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-api-key).

[![Enable Semantic Search and Q&A](/img/openai_experimental_setting.png)](/img/openai_experimental_setting.png)

Once enabled, embedding of your medical records will start. This process may take a minute to complete, depending on the number of records you have. Semantic search and Q&A will be available once the embedding process is complete.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
slug: whats-new-this-year-2024
title: What's New with Mere This Year
description: A lot has changed behind the scenes
authors:
name: Christopher Fu
title: Developer of Mere Medical
url: https://cfu288.com
image_url: https://files.meremedical.co/profile.jpg
authors: [cfu288]
toc_min_heading_level: 2
toc_max_heading_level: 5
hide_table_of_contents: false
Expand Down
5 changes: 5 additions & 0 deletions apps/docs/blog/authors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cfu288:
name: Christopher Fu
title: Developer of Mere Medical
url: https://cfu288.com
image_url: https://files.meremedical.co/profile.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/docs/static/vid/DoIHaveAnemiaDemo.mp4
Binary file not shown.
Binary file added apps/docs/static/vid/ExactSearch.mp4
Binary file not shown.
Binary file added apps/docs/static/vid/SemanticSearch.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion libs/vector-storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ interface IVSOptions {
openAIApiKey: string; // The OpenAI API key used for generating embeddings.
maxSizeInMB?: number; // The maximum size of the storage in megabytes. Defaults to 2GB
debounceTime?: number; // The debounce time in milliseconds for saving to IndexedDB. Defaults to 0.
openaiModel?: string; // The OpenAI model used for generating embeddings. Defaults to 'text-embedding-ada-002'.
openaiModel?: string; // The OpenAI model used for generating embeddings. Defaults to 'text-embedding-3-large'.
}
```

Expand Down
2 changes: 1 addition & 1 deletion libs/vector-storage/src/types/IVSOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface IVSOptions<T> {
openAIApiKey?: string; // The OpenAI API key used for generating embeddings.
maxSizeInMB?: number; // The maximum size of the storage in megabytes. Defaults to 4.8. Cannot exceed 5.
debounceTime?: number; // The debounce time in milliseconds for saving to local storage. Defaults to 0.
embeddingModel?: string; // The embedding model used for generating embeddings. Defaults to 'text-embedding-ada-002'.
embeddingModel?: string; // The embedding model used for generating embeddings. Defaults to 'text-embedding-3-large'.
embedTextsFn?: (texts: string[]) => Promise<number[][]>; // Option for custom embedding function
rxdb?: RxDatabase<T>; // The RxDB database instance. Defaults to the global database instance.
}

0 comments on commit f69b56f

Please sign in to comment.