wisent


Namewisent JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/wisent-ai/wisent
SummaryClient library for interacting with the Wisent backend services
upload_time2025-03-03 00:11:52
maintainerNone
docs_urlNone
authorWisent Team
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Wisent

A Python client library for interacting with the Wisent backend services.

## Installation

```bash
pip install wisent
```

## Features

- **Activations**: Extract and send model activations to the Wisent backend
- **Control Vectors**: Retrieve and apply control vectors for model inference
- **Inference**: Utilities for applying control vectors during inference
- **Utilities**: Helper functions for common tasks

## Quick Start

```python
from wisent import WisentClient

# Initialize the client
client = WisentClient(api_key="your_api_key", base_url="https://api.wisent.ai")

# Extract activations from a model and send to backend
activations = client.activations.extract(
    model_name="mistralai/Mistral-7B-Instruct-v0.1",
    prompt="Tell me about quantum computing",
    layers=[0, 12, 24]
)

# Get a control vector from the backend
control_vector = client.control_vector.get(
    name="helpful",
    model="mistralai/Mistral-7B-Instruct-v0.1"
)

# Apply a control vector during inference
response = client.inference.generate_with_control(
    model_name="mistralai/Mistral-7B-Instruct-v0.1",
    prompt="Tell me about quantum computing",
    control_vectors={"helpful": 0.8, "concise": 0.5}
)

# Print the response
print(response.text)
```

## Advanced Usage

### Extracting Activations

```python
from wisent.activations import ActivationExtractor

# Create an extractor
extractor = ActivationExtractor(
    model_name="mistralai/Mistral-7B-Instruct-v0.1",
    device="cuda"
)

# Extract activations for a specific prompt
activations = extractor.extract(
    prompt="Tell me about quantum computing",
    layers=[0, 12, 24],
    tokens_to_extract=[-10, -1]  # Extract last 10 tokens and final token
)

# Send activations to the Wisent backend
from wisent import WisentClient
client = WisentClient(api_key="your_api_key")
client.activations.upload(activations)
```

### Working with Control Vectors

```python
from wisent.control_vector import ControlVectorManager

# Initialize the manager
manager = ControlVectorManager(api_key="your_api_key")

# Get a control vector
helpful_vector = manager.get("helpful", model="mistralai/Mistral-7B-Instruct-v0.1")

# Combine multiple vectors
combined_vector = manager.combine(
    vectors={
        "helpful": 0.8,
        "concise": 0.5
    },
    model="mistralai/Mistral-7B-Instruct-v0.1"
)

# Apply during inference
from wisent.inference import Inferencer
inferencer = Inferencer(model_name="mistralai/Mistral-7B-Instruct-v0.1")
response = inferencer.generate(
    prompt="Tell me about quantum computing",
    control_vector=combined_vector,
    method="caa"  # Context-Aware Addition
)
```

## Documentation

For full documentation, visit [docs.wisent.ai](https://docs.wisent.ai).

## License

MIT

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wisent-ai/wisent",
    "name": "wisent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Wisent Team",
    "author_email": "info@wisent.ai",
    "download_url": "https://files.pythonhosted.org/packages/6c/72/1a63f9c2e5fe2accd236b3ea18844e8f0d224353e72097cbddbef6a83409/wisent-0.1.1.tar.gz",
    "platform": null,
    "description": "# Wisent\n\nA Python client library for interacting with the Wisent backend services.\n\n## Installation\n\n```bash\npip install wisent\n```\n\n## Features\n\n- **Activations**: Extract and send model activations to the Wisent backend\n- **Control Vectors**: Retrieve and apply control vectors for model inference\n- **Inference**: Utilities for applying control vectors during inference\n- **Utilities**: Helper functions for common tasks\n\n## Quick Start\n\n```python\nfrom wisent import WisentClient\n\n# Initialize the client\nclient = WisentClient(api_key=\"your_api_key\", base_url=\"https://api.wisent.ai\")\n\n# Extract activations from a model and send to backend\nactivations = client.activations.extract(\n    model_name=\"mistralai/Mistral-7B-Instruct-v0.1\",\n    prompt=\"Tell me about quantum computing\",\n    layers=[0, 12, 24]\n)\n\n# Get a control vector from the backend\ncontrol_vector = client.control_vector.get(\n    name=\"helpful\",\n    model=\"mistralai/Mistral-7B-Instruct-v0.1\"\n)\n\n# Apply a control vector during inference\nresponse = client.inference.generate_with_control(\n    model_name=\"mistralai/Mistral-7B-Instruct-v0.1\",\n    prompt=\"Tell me about quantum computing\",\n    control_vectors={\"helpful\": 0.8, \"concise\": 0.5}\n)\n\n# Print the response\nprint(response.text)\n```\n\n## Advanced Usage\n\n### Extracting Activations\n\n```python\nfrom wisent.activations import ActivationExtractor\n\n# Create an extractor\nextractor = ActivationExtractor(\n    model_name=\"mistralai/Mistral-7B-Instruct-v0.1\",\n    device=\"cuda\"\n)\n\n# Extract activations for a specific prompt\nactivations = extractor.extract(\n    prompt=\"Tell me about quantum computing\",\n    layers=[0, 12, 24],\n    tokens_to_extract=[-10, -1]  # Extract last 10 tokens and final token\n)\n\n# Send activations to the Wisent backend\nfrom wisent import WisentClient\nclient = WisentClient(api_key=\"your_api_key\")\nclient.activations.upload(activations)\n```\n\n### Working with Control Vectors\n\n```python\nfrom wisent.control_vector import ControlVectorManager\n\n# Initialize the manager\nmanager = ControlVectorManager(api_key=\"your_api_key\")\n\n# Get a control vector\nhelpful_vector = manager.get(\"helpful\", model=\"mistralai/Mistral-7B-Instruct-v0.1\")\n\n# Combine multiple vectors\ncombined_vector = manager.combine(\n    vectors={\n        \"helpful\": 0.8,\n        \"concise\": 0.5\n    },\n    model=\"mistralai/Mistral-7B-Instruct-v0.1\"\n)\n\n# Apply during inference\nfrom wisent.inference import Inferencer\ninferencer = Inferencer(model_name=\"mistralai/Mistral-7B-Instruct-v0.1\")\nresponse = inferencer.generate(\n    prompt=\"Tell me about quantum computing\",\n    control_vector=combined_vector,\n    method=\"caa\"  # Context-Aware Addition\n)\n```\n\n## Documentation\n\nFor full documentation, visit [docs.wisent.ai](https://docs.wisent.ai).\n\n## License\n\nMIT\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Client library for interacting with the Wisent backend services",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/wisent-ai/wisent"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a7b1049d60092495f20a16f9cee3af6a9e19a007f93703e6b4d6bb7188d071de",
                "md5": "29f713fef40eeb7f7de514aab0060229",
                "sha256": "703697836d1f4706deeabef8044822f54b4344e4df0e30d12883ed3cd4ccbc9d"
            },
            "downloads": -1,
            "filename": "wisent-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "29f713fef40eeb7f7de514aab0060229",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 19390,
            "upload_time": "2025-03-03T00:11:48",
            "upload_time_iso_8601": "2025-03-03T00:11:48.446155Z",
            "url": "https://files.pythonhosted.org/packages/a7/b1/049d60092495f20a16f9cee3af6a9e19a007f93703e6b4d6bb7188d071de/wisent-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6c721a63f9c2e5fe2accd236b3ea18844e8f0d224353e72097cbddbef6a83409",
                "md5": "df270fc04d1b74be0eaa3181cd66e1ec",
                "sha256": "c0a8e4aff91476e81aba2b5a372cb6cddaca3347e2853a269ed87b1203f08198"
            },
            "downloads": -1,
            "filename": "wisent-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "df270fc04d1b74be0eaa3181cd66e1ec",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20575,
            "upload_time": "2025-03-03T00:11:52",
            "upload_time_iso_8601": "2025-03-03T00:11:52.173666Z",
            "url": "https://files.pythonhosted.org/packages/6c/72/1a63f9c2e5fe2accd236b3ea18844e8f0d224353e72097cbddbef6a83409/wisent-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-03-03 00:11:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wisent-ai",
    "github_project": "wisent",
    "github_not_found": true,
    "lcname": "wisent"
}
        
Elapsed time: 1.53267s