sample_id stringlengths 21 196 | text stringlengths 105 936k | metadata dict | category stringclasses 6
values |
|---|---|---|---|
mem0ai/mem0:evaluation/evals.py | import argparse
import concurrent.futures
import json
import threading
from collections import defaultdict
from metrics.llm_judge import evaluate_llm_judge
from metrics.utils import calculate_bleu_scores, calculate_metrics
from tqdm import tqdm
def process_item(item_data):
k, v = item_data
local_results = de... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/evals.py",
"license": "Apache License 2.0",
"lines": 62,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mem0ai/mem0:evaluation/generate_scores.py | import json
import pandas as pd
# Load the evaluation metrics data
with open("evaluation_metrics.json", "r") as f:
data = json.load(f)
# Flatten the data into a list of question items
all_items = []
for key in data:
all_items.extend(data[key])
# Convert to DataFrame
df = pd.DataFrame(all_items)
# Convert c... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/generate_scores.py",
"license": "Apache License 2.0",
"lines": 24,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mem0ai/mem0:evaluation/metrics/llm_judge.py | import argparse
import json
from collections import defaultdict
import numpy as np
from openai import OpenAI
from mem0.memory.utils import extract_json
client = OpenAI()
ACCURACY_PROMPT = """
Your task is to label an answer to a question as ’CORRECT’ or ’WRONG’. You will be given the following data:
(1) a quest... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/metrics/llm_judge.py",
"license": "Apache License 2.0",
"lines": 103,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/metrics/utils.py | """
Borrowed from https://github.com/WujiangXu/AgenticMemory/blob/main/utils.py
@article{xu2025mem,
title={A-mem: Agentic memory for llm agents},
author={Xu, Wujiang and Liang, Zujie and Mei, Kai and Gao, Hang and Tan, Juntao
and Zhang, Yongfeng},
journal={arXiv preprint arXiv:2502.12110},
y... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/metrics/utils.py",
"license": "Apache License 2.0",
"lines": 172,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/prompts.py | ANSWER_PROMPT_GRAPH = """
You are an intelligent memory assistant tasked with retrieving accurate information from
conversation memories.
# CONTEXT:
You have access to memories from two speakers in a conversation. These memories contain
timestamped information that may be relevant to answering th... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/prompts.py",
"license": "Apache License 2.0",
"lines": 115,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
mem0ai/mem0:evaluation/run_experiments.py | import argparse
import os
from src.langmem import LangMemManager
from src.memzero.add import MemoryADD
from src.memzero.search import MemorySearch
from src.openai.predict import OpenAIPredict
from src.rag import RAGManager
from src.utils import METHODS, TECHNIQUES
from src.zep.add import ZepAdd
from src.zep.search imp... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/run_experiments.py",
"license": "Apache License 2.0",
"lines": 64,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/src/langmem.py | import json
import multiprocessing as mp
import os
import time
from collections import defaultdict
from dotenv import load_dotenv
from jinja2 import Template
from langgraph.checkpoint.memory import MemorySaver
from langgraph.prebuilt import create_react_agent
from langgraph.store.memory import InMemoryStore
from langg... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/src/langmem.py",
"license": "Apache License 2.0",
"lines": 151,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/src/memzero/add.py | import json
import os
import threading
import time
from concurrent.futures import ThreadPoolExecutor
from dotenv import load_dotenv
from tqdm import tqdm
from mem0 import MemoryClient
load_dotenv()
# Update custom instructions
custom_instructions = """
Generate personal memories that follow these guidelines:
1. E... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/src/memzero/add.py",
"license": "Apache License 2.0",
"lines": 114,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/src/memzero/search.py | import json
import os
import time
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from dotenv import load_dotenv
from jinja2 import Template
from openai import OpenAI
from prompts import ANSWER_PROMPT, ANSWER_PROMPT_GRAPH
from tqdm import tqdm
from mem0 import MemoryClient
load_... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/src/memzero/search.py",
"license": "Apache License 2.0",
"lines": 188,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/src/openai/predict.py | import argparse
import json
import os
import time
from collections import defaultdict
from dotenv import load_dotenv
from jinja2 import Template
from openai import OpenAI
from tqdm import tqdm
load_dotenv()
ANSWER_PROMPT = """
You are an intelligent memory assistant tasked with retrieving accurate information f... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/src/openai/predict.py",
"license": "Apache License 2.0",
"lines": 103,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/src/rag.py | import json
import os
import time
from collections import defaultdict
import numpy as np
import tiktoken
from dotenv import load_dotenv
from jinja2 import Template
from openai import OpenAI
from tqdm import tqdm
load_dotenv()
PROMPT = """
# Question:
{{QUESTION}}
# Context:
{{CONTEXT}}
# Short answer:
"""
clas... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/src/rag.py",
"license": "Apache License 2.0",
"lines": 148,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/src/zep/add.py | import argparse
import json
import os
from dotenv import load_dotenv
from tqdm import tqdm
from zep_cloud import Message
from zep_cloud.client import Zep
load_dotenv()
class ZepAdd:
def __init__(self, data_path=None):
self.zep_client = Zep(api_key=os.getenv("ZEP_API_KEY"))
self.data_path = data_... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/src/zep/add.py",
"license": "Apache License 2.0",
"lines": 61,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mem0ai/mem0:evaluation/src/zep/search.py | import argparse
import json
import os
import time
from collections import defaultdict
from dotenv import load_dotenv
from jinja2 import Template
from openai import OpenAI
from prompts import ANSWER_PROMPT_ZEP
from tqdm import tqdm
from zep_cloud import EntityEdge, EntityNode
from zep_cloud.client import Zep
load_dote... | {
"repo_id": "mem0ai/mem0",
"file_path": "evaluation/src/zep/search.py",
"license": "Apache License 2.0",
"lines": 110,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/BitNet:utils/quantize_embeddings.py | #!/usr/bin/env python3
"""
Embedding Quantization Script
This script converts ggml-model-f32.gguf to multiple quantized versions
with different token embedding types.
"""
import subprocess
import os
import argparse
import re
import csv
from pathlib import Path
from datetime import datetime
class EmbeddingQuantizer:
... | {
"repo_id": "microsoft/BitNet",
"file_path": "utils/quantize_embeddings.py",
"license": "MIT License",
"lines": 388,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/BitNet:utils/tune_gemm_config.py | #!/usr/bin/env python3
"""
GEMM Configuration Tuning Script
This script automatically tunes ROW_BLOCK_SIZE, COL_BLOCK_SIZE, and PARALLEL_SIZE
to find the optimal configuration for maximum throughput (t/s).
"""
import subprocess
import os
import re
import csv
import shutil
from datetime import datetime
from pathlib imp... | {
"repo_id": "microsoft/BitNet",
"file_path": "utils/tune_gemm_config.py",
"license": "MIT License",
"lines": 306,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/BitNet:utils/convert-helper-bitnet.py | #!/usr/bin/env python3
import sys
import os
import shutil
import subprocess
from pathlib import Path
def run_command(command_list, cwd=None, check=True):
print(f"Executing: {' '.join(map(str, command_list))}")
try:
process = subprocess.run(command_list, cwd=cwd, check=check, capture_output=False, text... | {
"repo_id": "microsoft/BitNet",
"file_path": "utils/convert-helper-bitnet.py",
"license": "MIT License",
"lines": 113,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/BitNet:utils/preprocess-huggingface-bitnet.py | from safetensors import safe_open
from safetensors.torch import save_file
import torch
def quant_weight_fp16(weight):
weight = weight.to(torch.float)
s = 1.0 / weight.abs().mean().clamp_(min=1e-5)
new_weight = (weight * s).round().clamp(-1, 1) / s
return new_weight
def quant_model(input, output):
... | {
"repo_id": "microsoft/BitNet",
"file_path": "utils/preprocess-huggingface-bitnet.py",
"license": "MIT License",
"lines": 41,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/BitNet:gpu/convert_checkpoint.py | import json
import os
import re
import sys
from pathlib import Path
from typing import Optional
from dataclasses import dataclass
import torch
from einops import rearrange
from safetensors.torch import save_file
import model
from pack_weight import convert_weight_int8_to_int2
@torch.inference_mode()
def ... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/convert_checkpoint.py",
"license": "MIT License",
"lines": 87,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/BitNet:gpu/convert_safetensors.py | import re
import torch
from pathlib import Path
from safetensors.torch import load_file
from einops import rearrange
from dataclasses import dataclass
from typing import Optional
transformer_configs = {
"2B": dict(n_layer=30, n_head=20, dim=2560, vocab_size=128256, n_local_heads=5, intermediate_size=6912),
}
@dat... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/convert_safetensors.py",
"license": "MIT License",
"lines": 95,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/BitNet:gpu/generate.py | # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import json
import os
import readline # type: ignore # noqa
import sys
import time
from dataclasses import dat... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/generate.py",
"license": "MIT License",
"lines": 288,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/BitNet:gpu/model.py | # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional, Tuple, Union
import torch
from torch import nn
... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/model.py",
"license": "MIT License",
"lines": 298,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/BitNet:gpu/pack_weight.py | import torch
import numpy as np
def B_global_16x32_to_shared_load_16x32_layout(i, j):
"""
stride * 8 * (tx // HALF_WARP_expr)
+ (tx % 8) * stride
+ 16 * ((tx % HALF_WARP_expr) // 8)
"""
thread_id = i * 2 + j // 16
row = (thread_id // 16) * 8 + (threa... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/pack_weight.py",
"license": "MIT License",
"lines": 73,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/BitNet:gpu/sample_utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
@torch.compile
def top_p(probs: torch.Tensor, p: float) -> torch.Tensor:
"""
Perform top-... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/sample_utils.py",
"license": "MIT License",
"lines": 26,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/BitNet:gpu/stats.py | # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import time
from dataclasses import dataclass
from typing import Optional
@dataclass
class PhaseStats:
... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/stats.py",
"license": "MIT License",
"lines": 48,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/BitNet:gpu/test.py | import torch
from torch.utils import benchmark
from torch import nn
from pack_weight import convert_weight_int8_to_int2
from torch.profiler import profile, record_function, ProfilerActivity
import ctypes
import numpy as np
# set all seed
torch.manual_seed(42)
np.random.seed(42)
bitnet_lib = ctypes.CDLL('bitnet_kernel... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/test.py",
"license": "MIT License",
"lines": 81,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/BitNet:gpu/tokenizer.py | import os
from logging import getLogger
from pathlib import Path
from typing import (
AbstractSet,
cast,
Collection,
Dict,
Iterator,
List,
Literal,
Sequence,
TypedDict,
Union,
)
import tiktoken
from tiktoken.load import load_tiktoken_bpe
logger = getLogger(... | {
"repo_id": "microsoft/BitNet",
"file_path": "gpu/tokenizer.py",
"license": "MIT License",
"lines": 217,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/BitNet:run_inference_server.py | import os
import sys
import signal
import platform
import argparse
import subprocess
def run_command(command, shell=False):
"""Run a system command and ensure it succeeds."""
try:
subprocess.run(command, shell=shell, check=True)
except subprocess.CalledProcessError as e:
print(f"Error occur... | {
"repo_id": "microsoft/BitNet",
"file_path": "run_inference_server.py",
"license": "MIT License",
"lines": 54,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/VibeVoice:vllm_plugin/tests/test_api_auto_recover.py | #!/usr/bin/env python3
"""
Test VibeVoice vLLM API with Streaming, Hotwords, and Auto-Recovery.
This script tests ASR transcription with automatic recovery from repetition loops.
Supports optional hotwords to improve recognition of domain-specific terms.
Features:
- Streaming output with real-time repetition detectio... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vllm_plugin/tests/test_api_auto_recover.py",
"license": "MIT License",
"lines": 537,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/VibeVoice:vllm_plugin/scripts/start_server.py | #!/usr/bin/env python3
"""
VibeVoice vLLM ASR Server Launcher
One-click deployment script that handles:
1. Installing system dependencies (FFmpeg, etc.)
2. Installing VibeVoice Python package
3. Downloading model from HuggingFace
4. Generating tokenizer files
5. Starting vLLM server
Usage:
python3 start_server.py... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vllm_plugin/scripts/start_server.py",
"license": "MIT License",
"lines": 137,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/VibeVoice:vllm_plugin/inputs.py | """Audio input mapper for vLLM multimodal pipeline.
This module handles audio data loading and preprocessing for VibeVoice ASR inference.
It converts various audio input formats (path, bytes, numpy array) into tensors
that can be processed by the VibeVoice model.
"""
import torch
import numpy as np
from typing import ... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vllm_plugin/inputs.py",
"license": "MIT License",
"lines": 64,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
microsoft/VibeVoice:vllm_plugin/model.py | """
VibeVoice vLLM Plugin Model - Native Multimodal Integration
This module implements the VibeVoice ASR model with full vLLM multimodal registry
integration for speech-to-text inference.
"""
from typing import List, Optional, Tuple, Union, Dict, Any, Iterable, Mapping, Sequence
import os
import torch
import torch.nn... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vllm_plugin/model.py",
"license": "MIT License",
"lines": 1057,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vllm_plugin/tests/test_api.py | #!/usr/bin/env python3
"""
Test VibeVoice vLLM API with Streaming and Optional Hotwords Support.
This script tests ASR transcription via the vLLM OpenAI-compatible API.
By default, it runs standard transcription without hotwords.
Optionally, you can provide hotwords (context_info) to improve recognition
of domain-spe... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vllm_plugin/tests/test_api.py",
"license": "MIT License",
"lines": 227,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/VibeVoice:vllm_plugin/tools/generate_tokenizer_files.py | #!/usr/bin/env python3
"""
Standalone tool to generate VibeVoice tokenizer files from Qwen2 base.
Downloads base tokenizer from Qwen2 and patches it with VibeVoice-specific
audio tokens and chat template modifications.
Usage:
python generate_tokenizer_files.py --output /path/to/output [--compare /path/to/referenc... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vllm_plugin/tools/generate_tokenizer_files.py",
"license": "MIT License",
"lines": 481,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:demo/vibevoice_asr_gradio_demo.py | #!/usr/bin/env python
"""
VibeVoice ASR Gradio Demo
"""
import os
import sys
import torch
import numpy as np
import soundfile as sf
from pathlib import Path
import argparse
import time
import json
import gradio as gr
from typing import List, Dict, Tuple, Optional, Generator
import tempfile
import base64
import io
impo... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "demo/vibevoice_asr_gradio_demo.py",
"license": "MIT License",
"lines": 1012,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:demo/vibevoice_asr_inference_from_file.py | #!/usr/bin/env python
"""
VibeVoice ASR Batch Inference Demo Script
This script supports batch inference for ASR model and compares results
between batch processing and single-sample processing.
"""
import os
import sys
import torch
import numpy as np
from pathlib import Path
import argparse
import time
import json
i... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "demo/vibevoice_asr_inference_from_file.py",
"license": "MIT License",
"lines": 491,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/modeling_vibevoice.py | # copied from https://github.com/vibevoice-community/VibeVoice/blob/main/vibevoice/modular/modeling_vibevoice.py
from dataclasses import dataclass
from typing import Dict, List, Optional, Tuple, Union, Callable
from tqdm import tqdm
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.distrib... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/modeling_vibevoice.py",
"license": "MIT License",
"lines": 416,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/modeling_vibevoice_asr.py | from typing import List, Optional, Tuple, Union
import torch
import torch.nn as nn
from transformers.models.auto import AutoModel, AutoModelForCausalLM
from transformers.modeling_outputs import CausalLMOutput, BaseModelOutputWithPast
from transformers import modeling_utils
from transformers.modeling_utils import PreT... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/modeling_vibevoice_asr.py",
"license": "MIT License",
"lines": 444,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/processor/audio_utils.py | import os
import threading
import numpy as np
from subprocess import run
from typing import List, Optional, Union, Dict, Any
COMMON_AUDIO_EXTS = [
'.mp3', '.MP3', '.Mp3', # All case variations of mp3
'.m4a',
'.mp4', '.MP4',
'.wav', '.WAV',
'.m4v',
'.aac',
'.ogg',
'.mov', '.MOV',
... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/processor/audio_utils.py",
"license": "MIT License",
"lines": 179,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
microsoft/VibeVoice:vibevoice/processor/vibevoice_asr_processor.py | """
Processor class for VibeVoice ASR models.
"""
import os
import json
import math
import warnings
from typing import List, Optional, Union, Dict, Any, Tuple
import numpy as np
import torch
from transformers.tokenization_utils_base import BatchEncoding
from transformers.utils import TensorType, logging
from .vibevo... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/processor/vibevoice_asr_processor.py",
"license": "MIT License",
"lines": 488,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:demo/realtime_model_inference_from_file.py | import argparse
import os
import re
import traceback
from typing import List, Tuple, Union, Dict, Any
import time
import torch
import copy
import glob
from vibevoice.modular.modeling_vibevoice_streaming_inference import VibeVoiceStreamingForConditionalGenerationInference
from vibevoice.processor.vibevoice_streaming_pr... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "demo/realtime_model_inference_from_file.py",
"license": "MIT License",
"lines": 260,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:demo/vibevoice_realtime_demo.py | import argparse, os, uvicorn
def main():
p = argparse.ArgumentParser()
p.add_argument("--port", type=int, default=3000)
p.add_argument("--model_path", type=str, default="microsoft/VibeVoice-Realtime-0.5B")
p.add_argument("--device", type=str, default="cuda", choices=["cpu", "cuda", "mpx", "mps"])
p... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "demo/vibevoice_realtime_demo.py",
"license": "MIT License",
"lines": 13,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/VibeVoice:demo/web/app.py | import datetime
import builtins
import asyncio
import json
import os
import threading
import traceback
from pathlib import Path
from queue import Empty, Queue
from typing import Any, Callable, Dict, Iterator, Optional, Tuple, cast
import numpy as np
import torch
from fastapi import FastAPI, WebSocket
from fastapi.resp... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "demo/web/app.py",
"license": "MIT License",
"lines": 441,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/configuration_vibevoice.py | """ VibeVoice_AcousticTokenizer model configuration"""
from typing import Dict, List, Optional, Tuple
import torch
from transformers.configuration_utils import PretrainedConfig
from transformers.utils import logging
from transformers.models.qwen2.configuration_qwen2 import Qwen2Config
logger = logging.get_logger(_... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/configuration_vibevoice.py",
"license": "MIT License",
"lines": 349,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/configuration_vibevoice_streaming.py | """ VibeVoice Streaming model configuration"""
import torch
from transformers.configuration_utils import PretrainedConfig
from transformers.utils import logging
from transformers.models.qwen2.configuration_qwen2 import Qwen2Config
from .configuration_vibevoice import VibeVoiceAcousticTokenizerConfig, VibeVoiceDiffu... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/configuration_vibevoice_streaming.py",
"license": "MIT License",
"lines": 86,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/modeling_vibevoice_streaming.py | from dataclasses import dataclass
from typing import Dict, List, Optional, Tuple, Union, Callable
from tqdm import tqdm
import copy
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed as dist
from transformers.models.auto import AutoModel, AutoModelForCausalLM
from transformers... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/modeling_vibevoice_streaming.py",
"license": "MIT License",
"lines": 150,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/modeling_vibevoice_streaming_inference.py | from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Tuple, Union, Callable
from tqdm import tqdm
import inspect
import torch
import torch.nn as nn
from transformers.models.auto import AutoModel, AutoModelForCausalLM
from transformers.generation import GenerationMixin, GenerationConfig, Logi... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/modeling_vibevoice_streaming_inference.py",
"license": "MIT License",
"lines": 766,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/modular_vibevoice_diffusion_head.py | import math
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers.models.auto import AutoModel
from transformers.modeling_utils import PreTrainedModel
# from transformers.modeling_layers import GradientCheckpointingLayer
from transformers.activa... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/modular_vibevoice_diffusion_head.py",
"license": "MIT License",
"lines": 236,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/VibeVoice:vibevoice/modular/modular_vibevoice_text_tokenizer.py | """Tokenization classes for vibevoice."""
from typing import List, Optional, Union
from transformers.utils import logging
from transformers.models.qwen2.tokenization_qwen2 import Qwen2Tokenizer
from transformers.models.qwen2.tokenization_qwen2_fast import Qwen2TokenizerFast
logger = logging.get_logger(__name__)
cl... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/modular_vibevoice_text_tokenizer.py",
"license": "MIT License",
"lines": 264,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/modular_vibevoice_tokenizer.py | import math
import typing as tp
from functools import partial
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Tuple, Union
import copy
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers.models.auto import AutoModel
from transforme... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/modular_vibevoice_tokenizer.py",
"license": "MIT License",
"lines": 1010,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/modular/streamer.py | from __future__ import annotations
import torch
import asyncio
from queue import Queue
from typing import TYPE_CHECKING, Optional
from transformers.generation import BaseStreamer
class AudioStreamer(BaseStreamer):
"""
Audio streamer that stores audio chunks in queues for each sample in the batch.
This... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/modular/streamer.py",
"license": "MIT License",
"lines": 213,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/processor/vibevoice_processor.py | import math
import warnings
from typing import List, Optional, Union, Dict, Any, Tuple
import os
import re
import numpy as np
import torch
from transformers.tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from transformers.utils import TensorType, loggin... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/processor/vibevoice_processor.py",
"license": "MIT License",
"lines": 586,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/processor/vibevoice_streaming_processor.py | import math
import warnings
from typing import List, Optional, Union, Dict, Any, Tuple
import os
import re
import numpy as np
import torch
from transformers.tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from transformers.utils import TensorType, loggin... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/processor/vibevoice_streaming_processor.py",
"license": "MIT License",
"lines": 355,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/processor/vibevoice_tokenizer_processor.py | """
Processor class for VibeVoice models.
"""
import os
import json
import warnings
from typing import List, Optional, Union, Dict, Any
import numpy as np
import torch
from transformers.feature_extraction_utils import FeatureExtractionMixin
from transformers.utils import logging
from .audio_utils import AudioNormal... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/processor/vibevoice_tokenizer_processor.py",
"license": "MIT License",
"lines": 349,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/VibeVoice:vibevoice/schedule/dpm_solver.py | # Copyright 2024 TSAIL Team and The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/schedule/dpm_solver.py",
"license": "MIT License",
"lines": 920,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/VibeVoice:vibevoice/schedule/timestep_sampler.py | import math
import torch
class UniformSampler:
def __init__(self, timesteps = 1000):
self.timesteps = timesteps
def sample(self, batch_size, device):
return torch.randint(0, self.timesteps, (batch_size,), device=device)
class LogitNormalSampler:
def __init__(self, timesteps = 1000, m ... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/schedule/timestep_sampler.py",
"license": "MIT License",
"lines": 15,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
microsoft/VibeVoice:vibevoice/scripts/convert_nnscaler_checkpoint_to_transformers.py | #!/usr/bin/env python
# coding=utf-8
import argparse
import json
import os
from pathlib import Path
import re
import torch
from typing import Dict, List, Tuple
from vibevoice.modular.configuration_vibevoice import (
VibeVoiceConfig
)
from vibevoice.modular.modeling_vibevoice import VibeVoiceForConditionalGenerati... | {
"repo_id": "microsoft/VibeVoice",
"file_path": "vibevoice/scripts/convert_nnscaler_checkpoint_to_transformers.py",
"license": "MIT License",
"lines": 137,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
microsoft/graphrag:packages/graphrag/graphrag/index/operations/extract_graph/utils.py | # Copyright (C) 2026 Microsoft Corporation.
# Licensed under the MIT License
"""Utility functions for graph extraction operations."""
import logging
import pandas as pd
logger = logging.getLogger(__name__)
def filter_orphan_relationships(
relationships: pd.DataFrame,
entities: pd.DataFrame,
) -> pd.DataFr... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/index/operations/extract_graph/utils.py",
"license": "MIT License",
"lines": 43,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:tests/unit/indexing/operations/test_extract_graph.py | # Copyright (C) 2026 Microsoft Corporation.
# Licensed under the MIT License
"""Tests for extract_graph merge and orphan-filtering operations.
Validates that _merge_entities, _merge_relationships, and
filter_orphan_relationships correctly aggregate per-text-unit
extraction results and remove relationships whose sourc... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/indexing/operations/test_extract_graph.py",
"license": "MIT License",
"lines": 234,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/indexing/update/test_update_relationships.py | # Copyright (C) 2026 Microsoft Corporation.
# Licensed under the MIT License
"""Tests for incremental update merge operations.
Covers _update_and_merge_relationships and orphan-filtering
in the update pipeline, where old finalized data is merged
with delta data from a new indexing run.
"""
import pandas as pd
from g... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/indexing/update/test_update_relationships.py",
"license": "MIT License",
"lines": 193,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/indexing/test_finalize_graph.py | # Copyright (C) 2026 Microsoft
# Licensed under the MIT License
"""Tests for the finalize_graph streaming functions.
Covers _build_degree_map, finalize_entities, finalize_relationships,
and the orchestrating finalize_graph function.
"""
from typing import Any
import pytest
from graphrag.data_model.schemas import (
... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/indexing/test_finalize_graph.py",
"license": "MIT License",
"lines": 364,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:packages/graphrag-vectors/graphrag_vectors/filtering.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Generic filter expressions for vector store queries.
This module provides Pydantic-based filter expressions that can be:
1. Built programmatically using the F builder (for humans)
2. Generated as JSON by an LLM (structured output)
3. Seri... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-vectors/graphrag_vectors/filtering.py",
"license": "MIT License",
"lines": 295,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-vectors/graphrag_vectors/timestamp.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Timestamp explosion for vector store indexing.
Converts an ISO 8601 timestamp string into a set of filterable component
fields, enabling temporal queries like "find documents from a Monday" or
"find documents from Q3 2024" using the stand... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-vectors/graphrag_vectors/timestamp.py",
"license": "MIT License",
"lines": 80,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:tests/unit/vector_stores/test_filtering.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Unit tests for the filtering module (no backend required)."""
import json
from graphrag_vectors.filtering import (
AndExpr,
Condition,
F,
FilterExpr,
NotExpr,
Operator,
OrExpr,
)
# ── Condition.evaluate ─────... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/vector_stores/test_filtering.py",
"license": "MIT License",
"lines": 249,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/vector_stores/test_timestamp.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Unit tests for the timestamp module (no backend required)."""
import pytest
from graphrag_vectors.timestamp import (
TIMESTAMP_FIELDS,
_timestamp_fields_for,
explode_timestamp,
)
class TestExplodeTimestamp:
"""Tests for ... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/vector_stores/test_timestamp.py",
"license": "MIT License",
"lines": 93,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/indexing/operations/embed_text/test_embed_text.py | # Copyright (C) 2026 Microsoft
# Licensed under the MIT License
"""Unit tests for the streaming embed_text operation."""
from collections.abc import AsyncIterator
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
import numpy as np
import pytest
from graphrag.callbacks.noop_workflow_callba... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/indexing/operations/embed_text/test_embed_text.py",
"license": "MIT License",
"lines": 344,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/verbs/test_update_text_embeddings.py | # Copyright (C) 2026 Microsoft
# Licensed under the MIT License
"""Verb test for the update_text_embeddings workflow."""
from unittest.mock import patch
from graphrag.config.embeddings import all_embeddings
from graphrag.index.workflows.update_text_embeddings import (
run_workflow,
)
from tests.unit.config.util... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/verbs/test_update_text_embeddings.py",
"license": "MIT License",
"lines": 52,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:packages/graphrag/graphrag/data_model/row_transformers.py | # Copyright (C) 2026 Microsoft
"""Row-level type coercion for streaming Table reads.
Each transformer converts a raw ``dict[str, Any]`` row (as produced by
``csv.DictReader``, where every value is a string) into a dict with
properly typed fields. They serve the same purpose as the DataFrame-
based ``*_typed`` helper... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/data_model/row_transformers.py",
"license": "MIT License",
"lines": 202,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:tests/unit/storage/test_csv_table.py | # Copyright (C) 2026 Microsoft
"""Tests for CSVTable temp-file write strategy and streaming behavior.
When truncate=True, CSVTable writes to a temporary file and moves it
over the original on close(). This allows safe concurrent reads from
the original while writes are in progress — the pattern used by
create_final_t... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/storage/test_csv_table.py",
"license": "MIT License",
"lines": 196,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/indexing/test_cluster_graph.py | # Copyright (C) 2026 Microsoft
"""Tests for the cluster_graph operation.
These tests pin down the behavior of cluster_graph and its internal
_compute_leiden_communities function so that refactoring (vectorizing
iterrows, reducing copies, etc.) can be verified against known output.
"""
import pandas as pd
import pyte... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/indexing/test_cluster_graph.py",
"license": "MIT License",
"lines": 239,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/indexing/test_create_communities.py | # Copyright (C) 2026 Microsoft
"""Tests for the create_communities pure function.
These tests pin down the behavior of the create_communities function
independently of the workflow runner, so that refactoring (vectorizing
the per-level loop, streaming entity reads, streaming writes, etc.)
can be verified against know... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/indexing/test_create_communities.py",
"license": "MIT License",
"lines": 525,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/csv_table.py | # Copyright (c) 2025 Microsoft Corporation.
# Licensed under the MIT Licenses
"""A CSV-based implementation of the Table abstraction for streaming row access."""
from __future__ import annotations
import csv
import inspect
import os
import shutil
import sys
import tempfile
from pathlib import Path
from typing import... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/csv_table.py",
"license": "MIT License",
"lines": 171,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/parquet_table.py | # Copyright (C) 2025 Microsoft
# Licensed under the MIT License
"""A Parquet-based implementation of the Table abstraction with simulated streaming."""
from __future__ import annotations
import inspect
from io import BytesIO
from typing import TYPE_CHECKING, Any, cast
import pandas as pd
from graphrag_storage.tabl... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/parquet_table.py",
"license": "MIT License",
"lines": 119,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/table.py | # Copyright (C) 2025 Microsoft
# Licensed under the MIT License
"""Table abstraction for streaming row-by-row access."""
from abc import ABC, abstractmethod
from collections.abc import AsyncIterator, Callable
from types import TracebackType
from typing import Any
from typing_extensions import Self
RowTransformer = ... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/table.py",
"license": "MIT License",
"lines": 101,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:tests/unit/prompt_tune/test_load_docs_in_chunks.py | # Copyright (C) 2025 Microsoft
# Licensed under the MIT License
"""Unit tests for load_docs_in_chunks function."""
import logging
from dataclasses import dataclass
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from graphrag.prompt_tune.loader.input import load_docs_in_chu... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/prompt_tune/test_load_docs_in_chunks.py",
"license": "MIT License",
"lines": 249,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:packages/graphrag/graphrag/graphs/compute_degree.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Compute node degree directly from a relationships DataFrame."""
import pandas as pd
def compute_degree(
relationships: pd.DataFrame,
source_column: str = "source",
target_column: str = "target",
) -> pd.DataFrame:
"""Com... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/graphs/compute_degree.py",
"license": "MIT License",
"lines": 35,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag/graphrag/graphs/connected_components.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Find connected components and the largest connected component from an edge list DataFrame."""
import pandas as pd
def connected_components(
relationships: pd.DataFrame,
source_column: str = "source",
target_column: str = "ta... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/graphs/connected_components.py",
"license": "MIT License",
"lines": 76,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag/graphrag/graphs/edge_weights.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Edge weight calculation utilities (PMI, RRF)."""
import numpy as np
import pandas as pd
def calculate_pmi_edge_weights(
nodes_df: pd.DataFrame,
edges_df: pd.DataFrame,
node_name_col: str = "title",
node_freq_col: str = "... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/graphs/edge_weights.py",
"license": "MIT License",
"lines": 88,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag/graphrag/graphs/hierarchical_leiden.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Hierarchical Leiden clustering on edge lists."""
from typing import Any
import graspologic_native as gn
def hierarchical_leiden(
edges: list[tuple[str, str, float]],
max_cluster_size: int = 10,
random_seed: int | None = 0xD... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/graphs/hierarchical_leiden.py",
"license": "MIT License",
"lines": 43,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag/graphrag/graphs/modularity.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Compute graph modularity directly from an edge list DataFrame."""
import logging
import math
from collections import defaultdict
import pandas as pd
from graphrag.config.enums import ModularityMetric
from graphrag.graphs.connected_compo... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/graphs/modularity.py",
"license": "MIT License",
"lines": 256,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag/graphrag/graphs/stable_lcc.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Produce a stable largest connected component from a relationships DataFrame.
"Stable" means the same input edge list always produces the same output,
regardless of the original row order. This is achieved by:
1. Filtering to the largest... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/graphs/stable_lcc.py",
"license": "MIT License",
"lines": 58,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:tests/unit/graphs/test_compute_degree.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Side-by-side tests comparing NetworkX compute_degree with DataFrame-based compute_degree_df."""
import json
from pathlib import Path
import networkx as nx
import pandas as pd
from graphrag.graphs.compute_degree import compute_degree as c... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/graphs/test_compute_degree.py",
"license": "MIT License",
"lines": 104,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/graphs/test_connected_components.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Side-by-side tests comparing NetworkX connected components with DataFrame-based implementation."""
import json
from pathlib import Path
import networkx as nx
import pandas as pd
from graphrag.graphs.connected_components import (
conn... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/graphs/test_connected_components.py",
"license": "MIT License",
"lines": 128,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/graphs/test_modularity.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Side-by-side tests for the DataFrame-based modularity utility."""
import json
import math
from collections import defaultdict
from pathlib import Path
from typing import Any
import networkx as nx
import pandas as pd
from graphrag.graphs.... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/graphs/test_modularity.py",
"license": "MIT License",
"lines": 204,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:tests/unit/graphs/test_stable_lcc.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Side-by-side tests for the DataFrame-based stable LCC utility."""
import json
from pathlib import Path
import networkx as nx
import pandas as pd
from graphrag.graphs.stable_lcc import stable_lcc
from pandas.testing import assert_frame_eq... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/graphs/test_stable_lcc.py",
"license": "MIT License",
"lines": 170,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:packages/graphrag/graphrag/index/run/profiling.py | # Copyright (C) 2025 Microsoft
# Licensed under the MIT License
"""Workflow profiling utilities."""
import time
import tracemalloc
from types import TracebackType
from typing import Self
from graphrag.index.typing.stats import WorkflowMetrics
class WorkflowProfiler:
"""Context manager for profiling workflow ex... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/index/run/profiling.py",
"license": "MIT License",
"lines": 49,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:tests/unit/indexing/test_profiling.py | # Copyright (C) 2025 Microsoft
# Licensed under the MIT License
"""Unit tests for WorkflowProfiler."""
import time
from graphrag.index.run.profiling import WorkflowProfiler
from graphrag.index.typing.stats import WorkflowMetrics
class TestWorkflowProfiler:
"""Tests for the WorkflowProfiler context manager."""
... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/indexing/test_profiling.py",
"license": "MIT License",
"lines": 73,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:packages/graphrag/graphrag/data_model/data_reader.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""A DataReader that loads typed dataframes from a TableProvider."""
import pandas as pd
from graphrag_storage.tables import TableProvider
from graphrag.data_model.dfs import (
communities_typed,
community_reports_typed,
covaria... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/data_model/data_reader.py",
"license": "MIT License",
"lines": 56,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag/graphrag/data_model/dfs.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""A package containing dataframe processing utilities."""
from typing import Any
import pandas as pd
from graphrag.data_model.schemas import (
COMMUNITY_CHILDREN,
COMMUNITY_ID,
COMMUNITY_LEVEL,
COVARIATE_IDS,
EDGE_DEGR... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag/graphrag/data_model/dfs.py",
"license": "MIT License",
"lines": 119,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/csv_table_provider.py | # Copyright (c) 2025 Microsoft Corporation.
# Licensed under the MIT License
"""CSV-based table provider implementation."""
import logging
import re
from io import StringIO
import pandas as pd
from graphrag_storage.file_storage import FileStorage
from graphrag_storage.storage import Storage
from graphrag_storage.ta... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/csv_table_provider.py",
"license": "MIT License",
"lines": 117,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:tests/unit/storage/test_csv_table_provider.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
import unittest
from io import StringIO
import pandas as pd
import pytest
from graphrag_storage import (
StorageConfig,
StorageType,
create_storage,
)
from graphrag_storage.tables.csv_table_provider import CSVTableProvider
clas... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/storage/test_csv_table_provider.py",
"license": "MIT License",
"lines": 90,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/table_provider_config.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Storage configuration model."""
from pydantic import BaseModel, ConfigDict, Field
from graphrag_storage.tables.table_type import TableType
class TableProviderConfig(BaseModel):
"""The default configuration section for table provide... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/table_provider_config.py",
"license": "MIT License",
"lines": 13,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/table_provider_factory.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Storage factory implementation."""
from collections.abc import Callable
from graphrag_common.factory import Factory, ServiceScope
from graphrag_storage.storage import Storage
from graphrag_storage.tables.table_provider import TableProv... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/table_provider_factory.py",
"license": "MIT License",
"lines": 61,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/table_type.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Builtin table storage implementation types."""
from enum import StrEnum
class TableType(StrEnum):
"""Enum for table storage types."""
Parquet = "parquet"
CSV = "csv"
| {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/table_type.py",
"license": "MIT License",
"lines": 8,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/parquet_table_provider.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Parquet-based table provider implementation."""
import logging
import re
from io import BytesIO
import pandas as pd
from graphrag_storage.storage import Storage
from graphrag_storage.tables.parquet_table import ParquetTable
from graphra... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/parquet_table_provider.py",
"license": "MIT License",
"lines": 113,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-storage/graphrag_storage/tables/table_provider.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Abstract base class for table providers."""
from abc import ABC, abstractmethod
from typing import Any
import pandas as pd
from graphrag_storage.tables.table import RowTransformer, Table
class TableProvider(ABC):
"""Provide a tabl... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-storage/graphrag_storage/tables/table_provider.py",
"license": "MIT License",
"lines": 81,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:tests/unit/storage/test_parquet_table_provider.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
import unittest
from io import BytesIO
import pandas as pd
import pytest
from graphrag_storage import (
StorageConfig,
StorageType,
create_storage,
)
from graphrag_storage.tables.parquet_table_provider import ParquetTableProvider... | {
"repo_id": "microsoft/graphrag",
"file_path": "tests/unit/storage/test_parquet_table_provider.py",
"license": "MIT License",
"lines": 66,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
microsoft/graphrag:packages/graphrag-cache/graphrag_cache/cache_config.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Cache configuration model."""
from graphrag_storage import StorageConfig, StorageType
from pydantic import BaseModel, ConfigDict, Field
from graphrag_cache.cache_type import CacheType
class CacheConfig(BaseModel):
"""The configurat... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-cache/graphrag_cache/cache_config.py",
"license": "MIT License",
"lines": 18,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-cache/graphrag_cache/cache_factory.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Cache factory implementation."""
from collections.abc import Callable
from graphrag_common.factory import Factory, ServiceScope
from graphrag_storage import Storage, create_storage
from graphrag_cache.cache import Cache
from graphrag_c... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-cache/graphrag_cache/cache_factory.py",
"license": "MIT License",
"lines": 63,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-cache/graphrag_cache/cache_key.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Create cache key."""
from typing import Any, Protocol, runtime_checkable
from graphrag_common.hasher import hash_data
@runtime_checkable
class CacheKeyCreator(Protocol):
"""Create cache key function protocol.
Args
----
... | {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-cache/graphrag_cache/cache_key.py",
"license": "MIT License",
"lines": 26,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
microsoft/graphrag:packages/graphrag-cache/graphrag_cache/cache_type.py | # Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License
"""Builtin cache implementation types."""
from enum import StrEnum
class CacheType(StrEnum):
"""Enum for cache types."""
Json = "json"
Memory = "memory"
Noop = "none"
| {
"repo_id": "microsoft/graphrag",
"file_path": "packages/graphrag-cache/graphrag_cache/cache_type.py",
"license": "MIT License",
"lines": 9,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | license |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.