semvec/pypi-packages huggingface dataset:
llm-detector 0.2.0
Transparent, probabilistic classification of text as human-generated or LLM-generated
License: MIT
Requires Python: >=3.11
Keywords: llm-detection, ai-detection, text-classification, machine-learning, nlp, natural-language-processing, gpt-detection, chatgpt-detection, ai-generated-text, human-vs-ai, text-analysis, statistical-nlp

# llm-detector

**Research WIP**: Transparent, probabilistic classification of text as human-generated or LLM-generated.

## Installation

```bash
pip install llm-detector
```

## Quick Start

```python
from llm_detector import classify_text

# Simple classification
result = classify_text("Your text here")
print(f"LLM probability: {result['p_llm']:.2%}")
print(f"Classification: {'LLM' if result['is_llm'] else 'Human'}")
```

## Advanced Usage

### Using the Runtime API

```python
from llm_detector import DetectorRuntime
from llm_detector.assets import default_artifacts

# Initialize detector with default models
with default_artifacts() as (model_path, baseline_path):
    detector = DetectorRuntime(
        model_path=model_path,
        baseline_path=baseline_path
    )

    # Single text classification
    result = detector.predict("This is a sample text.")
    print(f"LLM: {result.p_llm:.2%}, Human: {result.p_human:.2%}")

    # Access detailed metrics
    print(f"Confidence: {result.confidence:.4f}")
    print(f"Document metrics:", result.details['document_metrics'])
```

### Detailed Results with Diagnostics

```python
from llm_detector import classify_text

result = classify_text(
    "Your text here",
    include_diagnostics=True
)

# Access classification
print(f"Classification: {'LLM' if result['is_llm'] else 'Human'}")
print(f"LLM probability: {result['p_llm']:.4f}")
print(f"Confidence: {result['confidence']:.4f}")

# Diagnostic metrics for analysis
if 'diagnostics' in result:
    diag = result['diagnostics']
    print(f"Simple mean: {diag.get('simple_mean', 0):.4f}")
    print(f"Max score: {diag.get('max_score', 0):.4f}")
```

## CLI Usage

```bash
# Classify text from command line
llm-detector --text "Your text here"

# Classify from file
llm-detector --file input.txt

# Get detailed output with diagnostics
llm-detector --text "Your text" --show-diagnostics --json
```

## Research Notes

This is an active research project exploring transparent statistical methods for LLM detection. The approach combines:

- **Statistical features**: Lexical diversity, punctuation patterns, repetition metrics
- **Tokenizer divergence**: Cross-tokenizer efficiency and consistency metrics
- **Ensemble aggregation**: Logit-weighted mean with diagnostic fallbacks

Current limitations:
- Performance varies by text length (best with 3+ sentences)
- Optimized for general English text
- Continuous model updates as LLM capabilities evolve

## Development

```bash
# Install with development dependencies
pip install -e ".[dev,training]"

# Run tests
pytest

# Train custom models (requires training extras)
python -m llm_detector.training.cli --help
```

## License

MIT
glados-chat-lib 0.1
Talk with GLaDOS using Ollama + Piper TTS + Whisper STT
License: MIT
Requires Python: >=3.9

# GLaDOS Chat Library — Usage Guide

Talk with GLaDOS (Portal 2 style) via **Ollama** + **Piper TTS** + **Whisper STT**, either in your terminal or in Python scripts.

---

## Features

- **Interactive Chatting**
  - One-shot answers or sentence-by-sentence streaming.
- **Text-to-Speech (TTS)**
  - Uses Piper with the GLaDOS voice model.
- **Speech-to-Text (STT)**
  - Uses Whisper to transcribe microphone input.
- **Audio Device Control**
  - Choose and persist your preferred output device.
- **CLI with colors**
  - Clean, color-coded output for user and GLaDOS lines.
- **Sarcasm detection**
  - Optional helper to flag user sarcasm.

---

## Command Line Usage

Once installed, you have access to the `glados-cli` command.

### 1. Select your audio output device
```bash
glados-cli audiosource
```

- Lists all available audio devices.
- Prompts you to choose one.
- Saves your selection for future sessions in `~/.glados-cli.json`.

### 2. Start a chat session
```bash
glados-cli start
```

Plain text chat (no TTS/STT).  
Type `exit` or `quit` to leave.

### 3. Start with TTS
```bash
glados-cli start --tts
```

Replies are spoken in GLaDOS’s voice.

### 4. Start with Streaming
```bash
glados-cli start --stream
```

Replies print sentence-by-sentence as they’re generated.

### 5. Combine streaming + TTS
```bash
glados-cli start --stream --tts
```

Replies stream sentence-by-sentence and each is spoken aloud.

### 6. Override audio device (session only)
```bash
glados-cli start --tts --audiosource 27
```

Plays on device index `27` (from the device list).  
Does not affect your saved config.

### 7. Enable Speech-to-Text
```bash
glados-cli start --stt
```

If integrated with a mic, transcriptions are fed into the chat.

---

## Python Usage

Embed GLaDOS directly in your own scripts:

```python
from glados_chat_lib import GladosChat

# Create a chat instance
chat = GladosChat(enable_tts=True, enable_stt=False, model="llama2:7b")

# One-shot conversation
reply = chat.ask("Do you hate humans?")
print("GLaDOS:", reply)
chat.speak(reply)

# Streaming mode
for piece in chat.ask("Tell me about science.", stream=True):
    print(piece, end="", flush=True)
```

## Audio Devices

- Run `glados-cli audiosource` to choose and persist your output.
- To override without saving:
  ```bash
  glados-cli start --audiosource <index>
  ```
- To reset to default, delete `~/.glados-cli.json`.

---

## Quick Examples

**Hear GLaDOS out loud in two steps:**
```bash
glados-cli audiosource
glados-cli start --stream --tts
```

**Embed in Python (minimal TTS only):**
```python
from glados_chat_lib import GladosChat

chat = GladosChat(enable_tts=True)
print("GLaDOS:", chat.ask("Sing me a song about testing."))
```