⚡ Live Interactive Code Sandbox: AI Dev Tool: Doory OpenSource Canva
▶️ Run Code
💳 Unlock Source Code ($5)
📝 Editable Code Sandbox
```python # AI Dev Tool: LLM Capability Evaluator and PostgreSQL Vector Search Integration # ============================================================================== # This tool evaluates the capability of a given Large Language Model (LLM) and # integrates it with PostgreSQL Vector Search Extension for efficient querying. import os import psycopg2 from psycopg2 import errors from typing import Dict, List import numpy as np from sentence_transformers import SentenceTransformer # Define a function to evaluate LLM capability def evaluate_llm_capability(llm_model: str, input_text: str) -> Dict: """ Evaluates the capability of a given LLM model. Args: - llm_model (str): The name of the LLM model to evaluate. - input_text (str): The input text to use for evaluation. Returns: - A dictionary containing the evaluation results. """ try: # Initialize the LLM model model = SentenceTransformer(llm_model) # Generate embeddings for the input text embeddings = model.encode(input_text) # Evaluate the capability of the LLM model capability = np.mean(embeddings) # Return the evaluation results return {"llm_model": llm_model, "capability": capability
🖥️ Interactive Execution Terminal Console
⚡ Ready! Click ▶️ Run Code to execute code in browser terminal...