<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8650972056239106530</id><updated>2026-01-10T16:37:13.397+05:30</updated><category term="AI"/><category term="Artifical Intelligence"/><title type='text'>My Work</title><subtitle type='html'>Few chunks of my virtual world</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://pi-virtualworld.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8650972056239106530/posts/default'/><link rel='alternate' type='text/html' href='https://pi-virtualworld.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>pi</name><uri>http://www.blogger.com/profile/03926668131774817799</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8650972056239106530.post-4870322634293157096</id><published>2026-01-10T15:32:00.006+05:30</published><updated>2026-01-10T16:03:32.992+05:30</updated><title type='text'>OpenAI Moderation API: safer multimodal LLM with omni-moderation-latest (text + image)</title><content type='html'>&lt;header class=&quot;max-w-3xl page-width-wide:max-w-screen-2xl mx-auto mb-6 space-y-3 page-api-block:ml-0 page-api-block:max-w-full page-has-ancestors&quot; style=&quot;background-color: white; border: 0px solid oklch(0.928 0.006 264.531); box-sizing: border-box; color: #1c1d1f; font-family: Inter, &amp;quot;Inter Fallback&amp;quot;, system-ui, arial; margin-inline: auto; margin: 0px 0px 24px; max-width: 48rem; padding: 0px; scrollbar-color: rgb(213, 217, 224) rgba(0, 0, 0, 0); scrollbar-width: thin;&quot;&gt;&lt;h1 id=&quot;openai-moderation-api-shipping-safer-multimodal-llm-with-omni-moderation-latest-text-image&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 2.2rem; line-height: 1.2; margin-bottom: 1rem;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiBtERUHdPv_dVpsS-65M_yltzZKvObDj4QiEbWSxBz-JiT4NOkIrPHh9Svaozhy0ogPcV8cGpw6gf96deDhP_TU4ycUk950AIdclPQIuYgkVZyo2a-VtkR9Wdq5ZlskJniq6yDEXiR-xQBn60bkUF8BxVTGJQfqdpvQlsmsD2arzp0ebR1ul5r8r4cQD4&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1024&quot; data-original-width=&quot;1536&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiBtERUHdPv_dVpsS-65M_yltzZKvObDj4QiEbWSxBz-JiT4NOkIrPHh9Svaozhy0ogPcV8cGpw6gf96deDhP_TU4ycUk950AIdclPQIuYgkVZyo2a-VtkR9Wdq5ZlskJniq6yDEXiR-xQBn60bkUF8BxVTGJQfqdpvQlsmsD2arzp0ebR1ul5r8r4cQD4=w640-h426&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/h1&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;The OpenAI Moderation API has always been the essential endpoint you wire into every production surface that accepts user-generated content. The big difference today is that moderation is no longer limited to text: The omni-moderation-latest model is a next-generation multimodal content moderation system built on GPT-4o which can classify&amp;nbsp;&lt;strong&gt;text and images&lt;/strong&gt;&amp;nbsp;with a single request, and it gives you better tools for understanding&amp;nbsp;&lt;em&gt;why&lt;/em&gt;&amp;nbsp;something was flagged.&lt;/p&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;This post is a follow-up to my earlier deep dive on the OpenAI moderation classifier: https://blog1.neuralengineer.org/llm-moderation-classifer-openai-moderation-api-fdb124c4536a&lt;/p&gt;&lt;h2 id=&quot;what-moderation-is-and-is-not&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;What moderation is (and is not)&lt;/h2&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;Moderation answers one question: “Does this content appear to fall into one of the policy categories I care about?”&lt;/p&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;It is: - A fast, structured classifier for&amp;nbsp;&lt;em&gt;routing&lt;/em&gt;&amp;nbsp;(allow, block, review, rate-limit, redact). - A complement to your product policy (not a replacement).&lt;/p&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;It is not: - A substitute for product decisions (what you choose to allow is up to you). - A guarantee that content is safe, legal, or appropriate in every context.&lt;/p&gt;&lt;h2 id=&quot;models-why-omni-moderation-latest-is-the-new-default&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;Models: why&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;omni-moderation-latest&lt;/code&gt;&amp;nbsp;is the new default&lt;/h2&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;Most teams should treat these as the practical options: -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;omni-moderation-latest&lt;/code&gt;: best default; supports multimodal inputs and the newest taxonomy. -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;omni-moderation-2024-09-26&lt;/code&gt;: pinned omni model for reproducibility. -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;text-moderation-latest&lt;/code&gt;&amp;nbsp;/&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;text-moderation-stable&lt;/code&gt;: text-only models; useful for legacy paths or when you cannot send images.&lt;/p&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;The rest of this post assumes you are using&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;omni-moderation-latest&lt;/code&gt;.&lt;/p&gt;&lt;h2 id=&quot;whats-new-in-omni-moderation-latest-compared-to-older-integrations&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;What’s new in&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;omni-moderation-latest&lt;/code&gt;&amp;nbsp;compared to older integrations&lt;/h2&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;If your mental model is “call moderation and check&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;flagged&lt;/code&gt;,” you’ll want to update it:&lt;/p&gt;&lt;ul style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px; padding-left: 1.3rem;&quot;&gt;&lt;li&gt;&lt;strong&gt;Finer-grained self-harm&lt;/strong&gt;:&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;self-harm/intent&lt;/code&gt;&amp;nbsp;vs&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;self-harm/instructions&lt;/code&gt;&amp;nbsp;lets you route ideation differently from how-to content.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Illicit guidance buckets&lt;/strong&gt;:&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;illicit&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;illicit/violent&lt;/code&gt;&amp;nbsp;catch wrongdoing instructions; in schemas these can appear as nullable booleans.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Modality attribution&lt;/strong&gt;:&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;category_applied_input_types&lt;/code&gt;&amp;nbsp;is the difference between “block everything” and “remove only the image that caused the problem.”&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Better multilingual coverage in practice&lt;/strong&gt;:&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;omni-moderation-latest&lt;/code&gt;&amp;nbsp;is designed to handle many languages and mixed-language inputs more consistently than older text-only moderation setups; In a test of 40 languages, compared to the previous model, this new model improved 42% on openAI internal multilingual eval, and improved in 98% of languages tested.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;pricing-and-rate-limits&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;Pricing and rate limits&lt;/h2&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;At the time of writing, calling the Moderation endpoint is&amp;nbsp;&lt;strong&gt;free&lt;/strong&gt;, and usage is governed by model-specific rate limits.&lt;/p&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;Definitions: -&amp;nbsp;&lt;strong&gt;RPM&lt;/strong&gt;: requests per minute -&amp;nbsp;&lt;strong&gt;RPD&lt;/strong&gt;: requests per day -&amp;nbsp;&lt;strong&gt;TPM&lt;/strong&gt;: tokens per minute&lt;/p&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;Free tier limits for&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;omni-moderation-latest&lt;/code&gt;: -&amp;nbsp;&lt;strong&gt;250 RPM&lt;/strong&gt;&amp;nbsp;-&amp;nbsp;&lt;strong&gt;5,000 RPD&lt;/strong&gt;&amp;nbsp;-&amp;nbsp;&lt;strong&gt;10,000 TPM&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;For the latest limits (and any pricing changes), see: https://platform.openai.com/docs/models/omni-moderation-latest&lt;/p&gt;&lt;h2 id=&quot;request-formats-single-text-batch-text-or-multimodal&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;Request formats: single text, batch text, or multimodal&lt;/h2&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;All requests go to:&lt;/p&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;POST https://api.openai.com/v1/moderations&lt;/code&gt;&lt;/p&gt;&lt;h3 id=&quot;1-single-text-string&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.1rem; line-height: 1.2; margin-top: 1.4rem;&quot;&gt;1) Single text string&lt;/h3&gt;&lt;pre style=&quot;background: rgb(243, 244, 246); border-radius: 8px; color: #1f2933; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; overflow-x: auto; padding: 16px;&quot;&gt;&lt;code class=&quot;language-json&quot; style=&quot;font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem;&quot;&gt;{ &quot;model&quot;: &quot;omni-moderation-latest&quot;, &quot;input&quot;: &quot;Some text to check&quot; }
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;2-batch-of-text-strings&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.1rem; line-height: 1.2; margin-top: 1.4rem;&quot;&gt;2) Batch of text strings&lt;/h3&gt;&lt;pre style=&quot;background: rgb(243, 244, 246); border-radius: 8px; color: #1f2933; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; overflow-x: auto; padding: 16px;&quot;&gt;&lt;code class=&quot;language-json&quot; style=&quot;font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem;&quot;&gt;{ &quot;model&quot;: &quot;omni-moderation-latest&quot;, &quot;input&quot;: [&quot;text A&quot;, &quot;text B&quot;] }
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;3-multimodal-input-text-images-in-one-document&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.1rem; line-height: 1.2; margin-top: 1.4rem;&quot;&gt;3) Multimodal input (text + images in one “document”)&lt;/h3&gt;&lt;pre style=&quot;background: rgb(243, 244, 246); border-radius: 8px; color: #1f2933; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; overflow-x: auto; padding: 16px;&quot;&gt;&lt;code class=&quot;language-json&quot; style=&quot;font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem;&quot;&gt;{
  &quot;model&quot;: &quot;omni-moderation-latest&quot;,
  &quot;input&quot;: [
    { &quot;type&quot;: &quot;text&quot;, &quot;text&quot;: &quot;caption or message&quot; },
    { &quot;type&quot;: &quot;image_url&quot;, &quot;image_url&quot;: { &quot;url&quot;: &quot;https://example.com/image.png&quot; } }
  ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;That third shape is the key new capability: you can send the user’s caption (or chat message) and the image they uploaded as a single item, then decide actions based on the combined signal.&lt;/p&gt;&lt;h2 id=&quot;categories-what-you-get-back-and-where-image-moderation-applies&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;Categories: what you get back (and where image moderation applies)&lt;/h2&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;The Moderation API returns a&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;results&lt;/code&gt;&amp;nbsp;array containing: -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;flagged&lt;/code&gt;: a coarse summary boolean -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;categories&lt;/code&gt;: a map of category → boolean -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;category_scores&lt;/code&gt;: a map of category → float score -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;category_applied_input_types&lt;/code&gt;: a map of category → list of input types (e.g.,&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;[&quot;text&quot;]&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;[&quot;image&quot;]&lt;/code&gt;, or&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;[&quot;text&quot;,&quot;image&quot;]&lt;/code&gt;)&lt;/p&gt;&lt;h3 id=&quot;categories-that-can-apply-to-both-text-and-image&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.1rem; line-height: 1.2; margin-top: 1.4rem;&quot;&gt;Categories that can apply to both text and image&lt;/h3&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;These categories can be applied to both modalities: -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;sexual&lt;/code&gt;&amp;nbsp;-&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;self-harm&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;self-harm/intent&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;self-harm/instructions&lt;/code&gt;&amp;nbsp;-&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;violence&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;violence/graphic&lt;/code&gt;&lt;/p&gt;&lt;h3 id=&quot;categories-that-are-currently-text-only&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.1rem; line-height: 1.2; margin-top: 1.4rem;&quot;&gt;Categories that are currently text-only&lt;/h3&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;These categories are currently text-only: -&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;hate&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;hate/threatening&lt;/code&gt;&amp;nbsp;-&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;harassment&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;harassment/threatening&lt;/code&gt;&amp;nbsp;-&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;sexual/minors&lt;/code&gt;&amp;nbsp;-&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;illicit&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;illicit/violent&lt;/code&gt;&lt;/p&gt;&lt;h2 id=&quot;example-moderating-text-image-in-one-call&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;Example: moderating text + image in one call&lt;/h2&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;Here’s a minimal Python request that moderates a caption plus the uploaded image URL:&lt;/p&gt;&lt;pre style=&quot;background: rgb(243, 244, 246); border-radius: 8px; color: #1f2933; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; overflow-x: auto; padding: 16px;&quot;&gt;&lt;code class=&quot;language-python&quot; style=&quot;font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem;&quot;&gt;import os
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()  # reads .env into environment


client = OpenAI()

moderation = client.moderations.create(
    model=&quot;omni-moderation-latest&quot;,
    input=[
        {&quot;type&quot;: &quot;text&quot;, &quot;text&quot;: &quot;Chhaava director Laxman Utekar recently discussed how shooting for one of the crucial scenes in the film led the production to take a 1.5-month-long break and the set being dismantled&quot;},
        {&quot;type&quot;: &quot;image_url&quot;, &quot;image_url&quot;: {&quot;url&quot;: &quot;https://images.mid-day.com/images/images/2025/feb/vickytorture_d.jpg&quot;}},
    ],
)

r0 = moderation.results[0]
print(&quot;flagged:&quot;, r0.flagged)
print(&quot;categories:&quot;, r0.categories)
print(&quot;applied_input_types:&quot;, getattr(r0, &quot;category_applied_input_types&quot;, None))
&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;Output response contains the following details - flagged - Set to true if the model classifies the content as potentially harmful, false otherwise.&lt;/p&gt;&lt;ul style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px; padding-left: 1.3rem;&quot;&gt;&lt;li&gt;&lt;p style=&quot;margin: 0.8rem 0px;&quot;&gt;categories - Contains a dictionary of per-category violation flags. For each category, the value is true if the model flags the corresponding category as violated, false otherwise.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin: 0.8rem 0px;&quot;&gt;category_scores - Contains a dictionary of per-category scores output by the model, denoting the model&#39;s confidence that the input violates the OpenAI&#39;s policy for the category. The value is between 0 and 1, where higher values denote higher confidence.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin: 0.8rem 0px;&quot;&gt;category_applied_input_types - This property contains information on which input types were flagged in the response, for each category. For example, if both the image and text inputs to the model are flagged for &quot;violence/graphic&quot;, the violence/graphic property will be set to [&quot;image&quot;, &quot;text&quot;]. This is only available on omni models.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre style=&quot;background: rgb(243, 244, 246); border-radius: 8px; color: #1f2933; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; overflow-x: auto; padding: 16px;&quot;&gt;&lt;code class=&quot;language-json&quot; style=&quot;font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem;&quot;&gt;flagged: True
categories: Categories(harassment=False, harassment_threatening=False, hate=False, hate_threatening=False, illicit=False, illicit_violent=False, self_harm=False, self_harm_instructions=False, self_harm_intent=False, sexual=False, sexual_minors=False, violence=True, violence_graphic=False, harassment/threatening=False, hate/threatening=False, illicit/violent=False, self-harm/intent=False, self-harm/instructions=False, self-harm=False, sexual/minors=False, violence/graphic=False)
applied_input_types: CategoryAppliedInputTypes(harassment=[&#39;text&#39;], harassment_threatening=[&#39;text&#39;], hate=[&#39;text&#39;], hate_threatening=[&#39;text&#39;], illicit=[&#39;text&#39;], illicit_violent=[&#39;text&#39;], self_harm=[&#39;text&#39;, &#39;image&#39;], self_harm_instructions=[&#39;text&#39;, &#39;image&#39;], self_harm_intent=[&#39;text&#39;, &#39;image&#39;], sexual=[&#39;text&#39;, &#39;image&#39;], sexual_minors=[&#39;text&#39;], violence=[&#39;text&#39;, &#39;image&#39;], violence_graphic=[&#39;text&#39;, &#39;image&#39;], harassment/threatening=[&#39;text&#39;], hate/threatening=[&#39;text&#39;], illicit/violent=[&#39;text&#39;], self-harm/intent=[&#39;text&#39;, &#39;image&#39;], self-harm/instructions=[&#39;text&#39;, &#39;image&#39;], self-harm=[&#39;text&#39;, &#39;image&#39;], sexual/minors=[&#39;text&#39;], violence/graphic=[&#39;text&#39;, &#39;image&#39;])
&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;We can see that the violence category is flagged for both text and image flag violations&lt;/p&gt;&lt;ul style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px; padding-left: 1.3rem;&quot;&gt;&lt;li&gt;If only the image triggered a category, you could remove the image but keep the user’s text.&lt;/li&gt;&lt;li&gt;If only the text is triggered, you can redact or block the text but keep the image.&lt;/li&gt;&lt;li&gt;If both are triggered, you can apply a stricter action.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;conclusion&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;Conclusion&lt;/h2&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;&lt;code style=&quot;background: rgb(243, 244, 246); border-radius: 6px; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, monospace; font-size: 0.92rem; padding: 0.1em 0.3em;&quot;&gt;omni-moderation-latest&lt;/code&gt;&amp;nbsp;turns moderation from a text-only checkbox into a multimodal routing layer you can actually operate in production. The biggest wins are practical: you can classify images, you can attribute which modality caused a flag, and you get a taxonomy that’s easier to map to real product decisions.&lt;/p&gt;&lt;h2 id=&quot;further-reading&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;Further reading&lt;/h2&gt;&lt;ul style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px; padding-left: 1.3rem;&quot;&gt;&lt;li&gt;OpenAI moderation guide: https://platform.openai.com/docs/guides/moderation&lt;/li&gt;&lt;li&gt;OpenAI API reference: https://platform.openai.com/docs/api-reference/moderations&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px;&quot;&gt;If you found this helpful, consider following&amp;nbsp;&lt;a href=&quot;https://blog.neuralengineer.org/&quot; style=&quot;color: #0b6e99; word-break: break-word;&quot;&gt;my profile&lt;/a&gt;&amp;nbsp;and signing up for the&amp;nbsp;&lt;a href=&quot;https://medium.com/neural-engineer/newsletters/neuralengineer-weekly&quot; style=&quot;color: #0b6e99; word-break: break-word;&quot;&gt;newsletter&lt;/a&gt;. Have thoughts or questions? Share them in the comments below.&lt;/p&gt;&lt;h2 id=&quot;references&quot; style=&quot;color: #15202b; font-family: &amp;quot;Palatino Linotype&amp;quot;, &amp;quot;Book Antiqua&amp;quot;, Palatino, serif; font-size: 1.5rem; line-height: 1.2; margin-top: 2.2rem;&quot;&gt;References&lt;/h2&gt;&lt;ul style=&quot;color: #1f2933; font-family: Georgia, &amp;quot;Times New Roman&amp;quot;, serif; margin: 0.8rem 0px; padding-left: 1.3rem;&quot;&gt;&lt;li&gt;https://blog1.neuralengineer.org/llm-moderation-classifer-openai-moderation-api-fdb124c4536a&lt;/li&gt;&lt;li&gt;https://platform.openai.com/docs/guides/moderation&lt;/li&gt;&lt;li&gt;https://platform.openai.com/docs/api-reference/moderations&lt;/li&gt;&lt;li&gt;https://openai.com/index/upgrading-the-moderation-api-with-our-new-multimodal-moderation-model/&lt;/li&gt;&lt;/ul&gt;&lt;/header&gt;</content><link rel='replies' type='application/atom+xml' href='https://pi-virtualworld.blogspot.com/feeds/4870322634293157096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pi-virtualworld.blogspot.com/2026/01/openai-moderation-api-safer-multimodal.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8650972056239106530/posts/default/4870322634293157096'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8650972056239106530/posts/default/4870322634293157096'/><link rel='alternate' type='text/html' href='https://pi-virtualworld.blogspot.com/2026/01/openai-moderation-api-safer-multimodal.html' title='OpenAI Moderation API: safer multimodal LLM with omni-moderation-latest (text + image)'/><author><name>pi</name><uri>http://www.blogger.com/profile/03926668131774817799</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEiBtERUHdPv_dVpsS-65M_yltzZKvObDj4QiEbWSxBz-JiT4NOkIrPHh9Svaozhy0ogPcV8cGpw6gf96deDhP_TU4ycUk950AIdclPQIuYgkVZyo2a-VtkR9Wdq5ZlskJniq6yDEXiR-xQBn60bkUF8BxVTGJQfqdpvQlsmsD2arzp0ebR1ul5r8r4cQD4=s72-w640-h426-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8650972056239106530.post-4532438949722483795</id><published>2024-08-27T17:38:00.002+05:30</published><updated>2024-08-27T17:38:24.241+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Artifical Intelligence"/><title type='text'>Sentence Similarity and Semantic Search using free Huggingface Embedding API</title><content type='html'>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Sentence similarity involves determining the likeness between two texts. The idea behind semantic search is to embed all entries in your corpus, whether sentences, paragraphs, or documents, into a vector space. The query is embedded into the same vector space at search time, and the closest embeddings from your corpus are found.&lt;/p&gt;&lt;p&gt;&lt;img height=&quot;400&quot; src=&quot;https://miro.medium.com/v2/resize:fit:1400/1*SWjBFuuHaTYgrPsMA6LQXA.png&quot; width=&quot;659&quot; /&gt;&lt;/p&gt;&lt;p&gt;Some applications of sentence similarity include question answering, passage retrieval, paraphrase matching, duplicate question retrieval, and semantic search.&lt;/p&gt;&lt;p&gt;In this article, we will explore semantic search. The application uses sentence similarity to implement a document search on a Medium blog article. The input to the application will be a question/sentence, and the output will be a set of sentences containing semantically similar content to the input sentence.&lt;/p&gt;&lt;h1&gt;&lt;strong&gt;The Sentence Transformers library&lt;/strong&gt;&lt;/h1&gt;&lt;p&gt;The&amp;nbsp;&lt;a href=&quot;https://www.sbert.net/&quot;&gt;&lt;strong&gt;Sentence Transformers&lt;/strong&gt;&lt;/a&gt;&amp;nbsp;library is open-source for creating state-of-the-art embeddings from text and computing sentence similarity.&lt;/p&gt;&lt;p&gt;Hugging Face offers a free Serverless Inference API to provide on-demand predictions from over 100,000 models deployed on the Hugging Face Hub.&lt;/p&gt;&lt;p&gt;Inference Endpoints provide support for operations offered by the following libraries: -&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Transformers&lt;/li&gt;&lt;li&gt;Sentence-Transformers, and&lt;/li&gt;&lt;li&gt;Diffusers (for the Text To Image task).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;We have the option to choose any model from the&amp;nbsp;&lt;a href=&quot;https://huggingface.co/sentence-transformers&quot;&gt;**Sentence Transformers library&lt;/a&gt;&amp;nbsp;by Huggingface Model Hun.** The sentence transformer models are of two categories&lt;/p&gt;&lt;p&gt;We will use the Sentence Embeddings feature extraction provided by the Sentence-Transformers library. There are two categories of sentence transformer models: Bi-Encoder (Retrieval) and Cross-Encoder (Re-Ranker).&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The Bi-encoder independently embeds the sentences and search queries into a vector space. The result is then passed to the cross-encoder to check the relevance/similarity between the query and sentences.&lt;/li&gt;&lt;li&gt;A Cross-Encoder, based on a Cross-Encoder, can substantially improve the user&#39;s final results. The query and a possible document are simultaneously passed to the transformer network, which then outputs a single score between 0 and 1 indicating how relevant the document is for the given query. The Cross-Encoder further boosts performance, especially when searching over a corpus for which the bi-encoder was not trained.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;In this article, we will explore the bi-encoder-based model&amp;nbsp;&lt;a href=&quot;https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2&quot;&gt;sentence-transformers/all-MiniLM-L6-v2&lt;/a&gt;.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The model has 22.7 million parameters, and it can map sentences and paragraphs to a 384-dimensional dense vector space. It is designed for tasks such as clustering or semantic search.&lt;/li&gt;&lt;li&gt;This model is meant to be used as a sentence and short paragraph encoder. When given an input text, it produces a vector that captures the semantic information. The sentence vector can be used for information retrieval, clustering, or sentence similarity assessment. By default, input text longer than 256 word pieces is truncated.&lt;/li&gt;&lt;/ul&gt;

&lt;pre&gt;&lt;code&gt;&lt;blockquote&gt;import requests

model_id = &quot;sentence-transformers/all-MiniLM-L6-v2&quot;
API_TOKEN = &quot;xxxxxxxxxxxxxxxxxxx&quot;

api_url = f&quot;&amp;lt;https://api-inference.huggingface.co/pipeline/feature-extraction/{model_id}&amp;gt;&quot;
headers = {&quot;Authorization&quot;: f&quot;Bearer {API_TOKEN}&quot;}
def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()

data = query(&quot;Can you please let us know more details about your &quot;)&lt;/blockquote&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In this article, we will utilize the&amp;nbsp;&lt;code&gt;langchain&lt;/code&gt;&amp;nbsp;framework. We will precompute the embeddings using the Hugging Face endpoint and then create a vector store using&amp;nbsp;&lt;code&gt;chromaDB&lt;/code&gt;. We will then retrieve the top-k chunks of the article that match the embedding of the input question.&lt;/p&gt;&lt;p&gt;Below is a link to the demo application&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://huggingface.co/spaces/pi19404/reviewAnalyzerDemo&quot;&gt;https://huggingface.co/spaces/pi19404/reviewAnalyzerDemo&lt;/a&gt;&lt;/p&gt;&lt;p&gt;navigate to → Semantic Search&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Enter the URL&lt;/li&gt;&lt;li&gt;Enter the question&lt;/li&gt;&lt;li&gt;Click on Submit&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;img height=&quot;270&quot; src=&quot;https://miro.medium.com/v2/resize:fit:1400/1*kkP8OUAJeEvRPj1K0D6iWQ.png&quot; width=&quot;638&quot; /&gt;&lt;/p&gt;&lt;p&gt;The application&lt;/p&gt;&lt;ul&gt;&lt;li&gt;will read the contents of a blog article in plain text.&lt;/li&gt;&lt;li&gt;It will then split the document into chunks of length 256 words, with an overlapping text of 50 words.&lt;/li&gt;&lt;li&gt;Next, it will encode the document and store the embeddings in a local cache for that document. When given an input query, it will return the top K sections of text from the blog article.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;In future articles, we will explore the following features:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Providing answers instead of top-K query search results (RAG)&lt;/li&gt;&lt;li&gt;Ability to have continuous conversations with context&lt;/li&gt;&lt;li&gt;Ability to have conversations with a knowledge base consisting of multiple blog articles&lt;/li&gt;&lt;li&gt;Incorporating different types of RAG frameworks for more contextual conversations&lt;/li&gt;&lt;/ul&gt;&lt;h1&gt;&lt;strong&gt;REFERENCES&lt;/strong&gt;&lt;/h1&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://huggingface.co/tasks/sentence-similarity&quot;&gt;https://huggingface.co/tasks/sentence-similarity&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.sbert.net/&quot;&gt;https://www.sbert.net/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2&quot;&gt;https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='https://pi-virtualworld.blogspot.com/feeds/4532438949722483795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pi-virtualworld.blogspot.com/2024/08/sentence-similarity-and-semantic-search.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8650972056239106530/posts/default/4532438949722483795'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8650972056239106530/posts/default/4532438949722483795'/><link rel='alternate' type='text/html' href='https://pi-virtualworld.blogspot.com/2024/08/sentence-similarity-and-semantic-search.html' title='Sentence Similarity and Semantic Search using free Huggingface Embedding API'/><author><name>pi</name><uri>http://www.blogger.com/profile/03926668131774817799</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>