Learning

Tutorials: Implementing LVS and R_m

Hands-on Implementation Guides

Ready to implement the SYMBI framework in your own projects? These guides provide step-by-step instructions and code snippets to get you started.

1. How to Calculate R_m

To calculate the Resonance Metric for a conversation, follow these steps:

  1. Generate embeddings for the user input and the AI response using a compatible model (e.g., MiniLM).
  2. Calculate the cosine similarity (V_align) between these embeddings.
  3. Extract the entropy/perplexity from the LLM response object.
  4. Apply the weights as specified in our Resonance Metrics page.

Python Snippet

# Simple R_m implementation
def get_quick_resonance(input_text, response_text):
    v_align = model.encode_similarity(input_text, response_text)
    entropy = get_model_entropy(response_text)
    
    # Using standard weights
    return (1 + entropy) / (v_align * 0.5 + 0.5)

2. Generating Trust Receipts

Once you have your R_m score, you can package it into a verifiable Trust Receipt.

Python Snippet

from symbi_framework import TrustReceipt

# Create and sign receipt
receipt = TrustReceipt.issue(
    interaction_id="...",
    metrics={"score": 1.45, "status": "HIGH_RESONANCE"}
)

print(receipt.to_json())

3. Integration with SONATE

For users of the **Yseeku Platform**, integrating LVS is as simple as plugging into the@sonate/detect module. This module provides real-time monitoring of R_m across all your AI endpoints.