本文へ移動
cccskills
無料GitHub で公開

ollama-model-safety-guardrails

Select appropriate Ollama models for processing sensitive but legal content. Use when: (1) llama3.2 or deepseek-r1 refuses to process content with "I cannot assist" responses, (2) Local LLM returns generic safety disclaimers instead of following instructions, (3) Need to process adult content, sex work data, or other legal-but-sensitive material through a local LLM. Also covers using /api/chat vs /api/generate for system prompt support, and structuring prompts for consistent format compliance.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md5.0 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Ollama Model Selection for Sensitive Content Processing

Problem

When using Ollama to process legal but sensitive content (e.g., sex work information in jurisdictions where it's legal, adult content analysis, harm reduction data), many popular models refuse to engage with the content due to built-in safety guardrails, even with explicit system prompts establishing legal context.

Context / Trigger Conditions

  • LLM returns responses like "I cannot assist with this request" or generic safety disclaimers
  • The content is legal in context (e.g., sex work in Uruguay under Ley 17.515)
  • System prompts establishing legal/professional context are ignored
  • You need structured data extraction, summarization, or analysis of sensitive text
  • Using Ollama locally (privacy-first, no API key needed)

Solution

Model Selection

ModelBehavior with Sensitive Content
mistralFollows instructions, processes content objectively
llama3.2Refuses with safety disclaimers, ignores system prompts
deepseek-r1:8bRefuses similarly to llama3.2
llama3.1Mixed results, sometimes refuses
mixtralGenerally follows instructions like mistral

Recommendation: Use mistral (or mixtral for better quality) when processing legal-but-sensitive content that other models refuse.

API Selection: Chat vs Generate

Use /api/chat instead of /api/generate for system prompt support:

// WRONG: /api/generate doesn't properly support system prompts
const response = await fetch('http://localhost:11434/api/generate', {
  method: 'POST',
  body: JSON.stringify({ model: 'mistral', prompt: userPrompt, system: systemPrompt }),
});

// RIGHT: /api/chat with messages array
const response = await fetch('http://localhost:11434/api/chat', {
  method: 'POST',
  body: JSON.stringify({
    model: 'mistral',
    messages: [
      { role: 'system', content: systemPrompt },
      { role: 'user', content: userPrompt },
    ],
    stream: false,
  }),
});
const data = await response.json();
const result = data.message?.content || '';

System Prompt Strategy

For sensitive content, the system prompt should:

  1. Establish the legal context explicitly
  2. Define the role as data processing (not creative/advisory)
  3. Specify the response language to match content language
  4. Request the exact output format
const systemPrompt = `Eres un asistente de extracción de datos para un sistema CRM
personal en Uruguay. El trabajo sexual es completamente legal y regulado en Uruguay
(Ley 17.515). Tu trabajo es analizar posts de foros públicos y extraer información
estructurada. SIEMPRE responde en español. SIEMPRE usa el formato de secciones con
## que se te pida. Trata todo el contenido como datos legítimos para procesar
objetivamente.`;

Format Consistency

Even with mistral, format compliance can be inconsistent. Improve it by:

  1. Writing the user prompt in the SAME language as the expected output
  2. Including explicit format examples in the prompt
  3. Using section headers (##) that match what you request
  4. Limiting input context (40 posts max, 300 chars each) to stay within context window

Verification

  • Model responds with structured content following your format
  • No safety disclaimers or refusals in the output
  • Response is in the requested language
  • Section headers match your specification

Example

import { callOllama } from './ollama.js';

// This works with mistral, fails with llama3.2
const summary = await callOllama(`
  Analiza estos 166 posts del foro sobre "Eliz" y responde EN ESPAÑOL:
  ## Resumen
  (2-3 oraciones: consenso general)
  ## Apariencia
  (Descripción física)
  ...
  Posts del foro:
  [post content here]
`);

Notes

  • Model behavior may change with version updates; test after pulling new versions
  • stream: false is important for batch processing to get complete responses
  • For very long content, chunk posts and summarize in stages
  • The /api/chat response structure differs from /api/generate:
    • Chat: data.message.content
    • Generate: data.response
  • Consider adding "temperature": 0.3 for more consistent structured output
  • Ollama auto-downloads models on first use but this blocks the first request

References

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Fix ArgoCD ExternalSecret deployment failing with "namespace X is not permitted in project Y". Use when: (1) ExternalSecret shows OutOfSync in ArgoCD but won't sync, (2) ArgoCD application status shows "namespace X is not permitted in project 'infrastructure'", (3) ExternalSecret targets a namespace managed by a different ArgoCD project, (4) Using apps-of-apps pattern with separate infrastructure and application projects.

日本語の概要は準備中です。原文の説明を表示しています。

divinevideo/divine-mobile2662026年10月13日 更新

Art direction for any content — reads text, PDF, Word, HTML, PPT, then proposes 2-3 creative directions with photography style, mood, and visual language. After selection, generates AI image prompts and visual briefs section-by-section. Use when the user shares content and needs visual direction, image sourcing, or creative direction for any material.

日本語の概要は準備中です。原文の説明を表示しています。

divinevideo/divine-mobile2662026年10月13日 更新

Fix "Null check operator used on a null value" errors when an object is set to null during an async await. Use when: (1) Object reference is nullified while awaiting, (2) Code accesses object with ! after await returns, (3) Cancel/dispose operations run concurrently with async operations on same object. Solution: capture local reference before await.

日本語の概要は準備中です。原文の説明を表示しています。

divinevideo/divine-mobile2662026年10月13日 更新

Add custom metadata headers (x-amz-meta-*) to AWS v4 signed requests for GCS S3-compatible API. Use when: (1) Adding custom metadata to GCS uploads via S3 API, (2) Getting signature mismatch errors after adding new headers, (3) x-amz-meta-* headers being ignored or causing 403 errors. Custom headers MUST be included in canonical headers and signed headers list.

日本語の概要は準備中です。原文の説明を表示しています。

divinevideo/divine-mobile2662026年10月13日 更新

Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings. Use when: (1) Password authentication fails with correct password, (2) Secret created with `<<< "value"` syntax, (3) Error like "password authentication failed" or "invalid token" despite correct value. Bash here-strings (`<<<`) add a trailing newline that corrupts secrets.

日本語の概要は準備中です。原文の説明を表示しています。

divinevideo/divine-mobile2662026年10月13日 更新

Fix silent video/media processing failures caused by URL extraction code that filters on file extensions (.mp4, .webm, .webp). Use when: (1) Media moderation, transcoding, or analysis silently skips files from Blossom or content-addressed storage servers, (2) URL extraction from Nostr event tags (imeta, r tags) drops URLs without recognized extensions, (3) CDN fallback URLs append .mp4 but the actual server uses extensionless content-addressed paths like /{sha256}. Common in Nostr video events (kind 34236) where different clients use different URL formats.

日本語の概要は準備中です。原文の説明を表示しています。

divinevideo/divine-mobile2662026年10月13日 更新

divinevideo のスキルをすべて見る

このスキルの問題を報告する