Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesAdaptersDebuggingDeploymentEvaluationFallbacksLangSmithRun LLMs locallyModel comparisonPrivacyPydantic compatibilitySafetyAmazon Comprehend Moderation ChainConstitutional chainHugging Face prompt injection identificationLogical Fallacy chainModeration chainMoreGuidesSafetyModeration chainOn this pageModeration chainThis notebook walks through examples of how to use a moderation chain, and several common ways for doing so.
Moderation chains are useful for detecting text that could be hateful, violent, etc. This can be useful to apply on both user input, but also on the output of a Language Model.
Some API providers, like OpenAI, specifically prohibit you, or your end users, from generating some
types of harmful content. To comply with this (and to just generally prevent your application from being harmful)
you may often want to append a moderation chain to any LLMChains, in order to make sure any output
the LLM generates is not harmful.If the content passed into the moderation chain is harmful, there is not one best way to handle it,
it probably depends on your application. Sometimes you may want to throw an error in the Chain
(and have your application handle that). Other times, you may want to return something to
the user explaining that the text was harmful. There could be other ways to handle it.
This notebook walks through examples of how to use a moderation chain, and several common ways for doing so.
This notebook walks through examples of how to use a moderation chain, and several common ways for doing so. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesAdaptersDebuggingDeploymentEvaluationFallbacksLangSmithRun LLMs locallyModel comparisonPrivacyPydantic compatibilitySafetyAmazon Comprehend Moderation ChainConstitutional chainHugging Face prompt injection identificationLogical Fallacy chainModeration chainMoreGuidesSafetyModeration chainOn this pageModeration chainThis notebook walks through examples of how to use a moderation chain, and several common ways for doing so.
Moderation chains are useful for detecting text that could be hateful, violent, etc. This can be useful to apply on both user input, but also on the output of a Language Model.
Some API providers, like OpenAI, specifically prohibit you, or your end users, from generating some
types of harmful content. To comply with this (and to just generally prevent your application from being harmful)
you may often want to append a moderation chain to any LLMChains, in order to make sure any output
the LLM generates is not harmful.If the content passed into the moderation chain is harmful, there is not one best way to handle it,
it probably depends on your application. Sometimes you may want to throw an error in the Chain
(and have your application handle that). Other times, you may want to return something to
the user explaining that the text was harmful. There could be other ways to handle it.