Similarity Detection
The system uses artificial intelligence to automatically detect and group similar grievances, facilitating identification of recurring issues and batch processing.
Overview
┌─────────────────────────────────────────────────────────────────────────┐
│ SIMILARITY PIPELINE │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ GRIEVANCES VECTORIZATION CLUSTERING GROUPS │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Text │ ──▶ │ TF-IDF │ ──▶ │ Cosine │ ──▶ │ Similar │ │
│ │ grievance│ │ Cohere │ │ Similarity│ │ groups │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Technologies used
The system combines two vectorization approaches:
| Method | Description | Advantages |
|---|---|---|
| TF-IDF | Term Frequency-Inverse Document Frequency | Fast, works offline |
| Cohere Embeddings | Semantic embeddings via Cohere API | Deep contextual understanding |
Access
Similarity detection is visible in:
- Grievance list: Grouping icon on similar grievances
- Grievance detail: "Similar grievances" section at bottom of page
- Reports: Grievance cluster analysis
Similar groups
Display in list
Grouped grievances are displayed with:
| Element | Description |
|---|---|
| Group icon | Indicates group membership |
| Similar count | Badge with number of linked grievances |
| Similarity score | Similarity percentage (70-100%) |
Expand/Collapse groups
In the grievance list:
- Click the ▶ icon to expand a group
- Similar grievances appear as a sub-list
- Click ▼ to collapse the group
Similarity threshold
The system considers two grievances as similar if their score exceeds 70%.
| Score | Interpretation |
|---|---|
| 90-100% | Very similar (possible duplicate) |
| 80-89% | Similar (same issue) |
| 70-79% | Potentially related |
| < 70% | Not grouped |
Use cases
Identify recurring issues
- Access the grievance list
- Filter by category or region
- Observe similarity groups
- Identify recurring patterns
Batch processing
For very similar grievances:
- Identify the group
- Process the main grievance
- Apply the same resolution to linked grievances
- Document cross-reference in each grievance
Detect duplicates
Grievances with a score > 90% may be duplicates:
- Verify complainant information
- Compare creation dates
- If duplicate confirmed, merge or close one of the grievances
Configuration
Clustering activation
Clustering is enabled by default. To configure:
Environment variables:
| Variable | Description | Default |
|---|---|---|
COHERE_API_KEY | Cohere API key for embeddings | - |
SIMILARITY_THRESHOLD | Similarity threshold (0-1) | 0.7 |
ENABLE_SIMILARITY | Enable/disable | true |
Degraded mode
If Cohere API is unavailable:
- The system uses TF-IDF only
- Quality remains good for similar texts
- Less performant on rephrased content
Technical operation
Processing pipeline
- Extraction: Grievance text (subject + description) is extracted
- Cleaning: Punctuation removal, normalization
- Vectorization: Transformation into numeric vector
- Similarity calculation: Cosine distance between vectors
- Clustering: Grouping by threshold
Automatic update
Clustering is recalculated:
- On creation of a new grievance
- When description is modified
- Via daily scheduled task (batch)
Statistics
In reports
The Reports > Grievances tab displays:
| Indicator | Description |
|---|---|
| Number of clusters | Total identified groups |
| Average size | Average grievances per group |
| Top clusters | Most important groups |
| Evolution | Recurring issue trends |
Analysis by category
Clusters can be analyzed by:
- Grievance category
- Geographic region
- Time period
- Priority
Best practices
:::tip Recommendations
- Examine large clusters: They indicate a systemic issue
- Verify duplicates: Score > 90% = manual verification
- Document links: Reference linked grievances in comments
- Process as group: Similar grievances often deserve a coordinated response :::
Required permissions
| Action | Permission |
|---|---|
| View similar groups | plaintes.view |
| Configure clustering | parametres.edit |
Limitations
- Clustering works better with detailed descriptions
- Very short grievances may be misclassified
- Mixed languages (Portuguese/Creole) may affect accuracy