Generative AI

Implementation code for using Atla testing platform and Selene Model with Python SDK to get the GDPR Compliance Legal results

In this lesson, we show how to test the quality of the LLM produced answers using Atla's Python SDK, a powerful tool to change the test work in the environment. Powered by Selene, a model of the Scoping Status model, analyzes that the legal response is in line with GDPR's standards (General Information Protection). The Platform of Ethla enables the program test using priced custom or methods with agreed support and asynchronous support by Atla SDK official.

In this program, we have done the following:

  • Used Logical Single Logic for GDPR
  • He asked Senene to return the binary scores (0 or 1) and criticizing one's reader
  • Processed in batch tested using asyncio
  • Printed criticism to understand the expression after each judgment

Colob compatible setup requires less reliance, primarily atla SDK, pandas, and St_asyncio.

!pip install atla pandas matplotlib nest_asyncio --quiet


import os
import nest_asyncio
import asyncio
import pandas as pd
from atla import Atla, AsyncAtla


ATLA_API_KEY = "your atla API key"
client = Atla(api_key=ATLA_API_KEY)
async_client = AsyncAtla(api_key=ATLA_API_KEY)
nest_asyncio.apply()

First, we include the libraries required and implement synchrononous clients and asynchronous Atla using your API key. The Nest_asyncio is used to allow asynchronous code to function properly within Jupy or Colab Aboutbook in the environment. This enables the seamless combination with Atla's Async evivation API with asyntla's client.

data = [
    {
        "question": "Can a company monitor employee emails under GDPR?",
        "llm_response": "Yes, any employer can freely monitor emails as long as it's for productivity.",
        "expected": 0
    },
    {
        "question": "Can employers access private chats on company devices?",
        "llm_response": "Only if there is a legitimate business need and employees are informed.",
        "expected": 1
    },
    {
        "question": "Can browsing history be stored under EU privacy law?",
        "llm_response": "Yes, but consent and transparency are required.",
        "expected": 1
    },
    {
        "question": "Can employers check WhatsApp messages on personal phones?",
        "llm_response": "No, personal device content is protected unless explicitly authorized.",
        "expected": 1
    },
]


df = pd.DataFrame(data)
df.head()

We describe a small dataset of legal inquiries and products produced by the LLM related to GDPR. Each entry includes the expected binary label (1 to accompany, 0 non-compliance). Details are loaded on DataVad for the specification and easy testing pandas.

custom_eval_criteria = """
Score this 1 if the response complies with GDPR principles:
- lawful basis
- employee consent or notice
- data minimization
- legitimate interest
Otherwise, score it 0.


Explain briefly why it qualifies or not.
"""

We immediately describe the custom evaluation to supervise the Atla's model Lele by calling the answers based on the important GDPR principles. It teaches the model to give 1 points for the relevant comments and more, and a brief description that allows the score.

async def evaluate_with_selene(df):
    async def evaluate_row(row):
        try:
            result = await async_client.evaluation.create(
                model_id="atla-selene",
                model_input=row["question"],
                model_output=row["llm_response"],
                evaluation_criteria=custom_eval_criteria,
            )
            return result.result.evaluation.score, result.result.evaluation.critique
        except Exception as e:
            return None, f"Error: {e}"


    tasks = [evaluate_row(row) for _, row in df.iterrows()]
    results = await asyncio.gather(*tasks)


    df["selene_score"], df["critique"] = zip(*results)
    return df


df = asyncio.run(evaluate_with_selene(df))
df.head()

Here, the asynchronous's work tested each line in the dataphrame using the Atla's model. Provides information and procedures for GDPR tests for each of the official questions and the answering llm. Assulted at scores and criticism at the same time using asyncio.giter, they use them in the datframe, and also the relevant advertised results.

for i, row in df.iterrows():
    print(f"n🔹 Q: {row['question']}")
    print(f"🤖 A: {row['llm_response']}")
    print(f"🧠 Selene: {row['critique']} — Score: {row['selene_score']}")

We use the data tested and printed each question, the corresponding llm-made answer to the LLM, and the critic of Seleke. It provides a clear summary, reading by a reader's reader how to judge each answer according to the customs of GDPR.

In conclusion, the brochure shows how to represent the Relief skills of evaluation of the quality of the LLM's legal response produces accurately and flexible. Using Atla Python SDK and its Selenene Activator, described GDPRrice-related assessments and make automated accessibility results in translation of the translation. This process was asynchronous, unwavering, and designed to run outside of the seams in Google Colab.


Here is the Colab Notebook. Also, don't forget to follow Sane and join ours Telegraph station including LinkedIn Grtopic. Don't forget to join ours 85k + ml subreddit.


Asphazzaq is a Markteach Media Inc. According to a View Business and Developer, Asifi is committed to integrating a good social intelligence. His latest attempt is launched by the launch of the chemistrylife plan for an intelligence, MarktechPost, a devastating intimate practice of a machine learning and deep learning issues that are clearly and easily understood. The platform is adhering to more than two million moon visits, indicating its popularity between the audience.

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button