fix: strengthen entity filtering for ad/business content

- Add marketing metadata to 'Not allowed' list in ontology prompt
- Strengthen exclude_self filter instruction
- Add exclude_rules support from template filter rules
- Update business_ad template with more excluded types
This commit is contained in:
Kunthawat Greethong
2026-06-26 12:19:45 +07:00
parent dec6bda349
commit dd3db561e5
4 changed files with 53 additions and 18 deletions

View File

@@ -53,6 +53,9 @@ Therefore, **entities must be real-world subjects that can speak and interact on
- Abstract concepts (such as "public opinion", "emotion", "trend")
- Topics/subjects (such as "academic integrity", "education reform")
- Viewpoints/attitudes (such as "supporters", "opponents")
- Marketing/advertising metadata (such as "campaign name", "ad position", "ad channel", "ad format", "brand name")
- The entity that created the uploaded content (e.g., if the data is an ad, do NOT create an entity for the advertiser/brand)
- Non-human concepts that cannot speak or interact on social media
## Output Format
@@ -221,14 +224,21 @@ class OntologyGenerator:
if exclude_self:
filter_instruction += (
"- IMPORTANT: The uploaded data is from a business/brand/advertiser. "
"Do NOT create entity types for the business/brand that created this content. "
"Only create entities for the TARGET AUDIENCE, competitors, influencers, media, etc.\n"
"- CRITICAL: The uploaded data is from a business/brand/advertiser. "
"Do NOT create entity types for: the business itself, its brand name, campaign names, "
"ad positions, ad channels, ad formats, or any marketing metadata. "
"ONLY create entity types for real people/organizations who would REACT to this content: "
"target audience segments, competitors, influencers, media outlets, consumer groups.\n"
)
if exclude_types:
filter_instruction += f"- Do NOT create entity types matching: {', '.join(exclude_types)}\n"
# Add custom exclude rules from template
exclude_rules = template_filter_rules.get('exclude_rules', [])
for rule in exclude_rules:
filter_instruction += f"- {rule}\n"
if focus:
filter_instruction += f"- Focus entity types on: {focus}\n"