Skip to main content

Web apps to inspect & engineer NN activations.

Project description

psAI ops apehex logo

License Latest

A collection of experimental web apps to inspect & engineer the activations of LLMs.

It is a WIP, some apps are not fully functional yet.

The human / LLM detector is improving though:

Screenshot de-generate

Installation

The package is available on pypi:

pip install -U psaiops

All the apps run on a single GPU and can be launched from a Google Colab notebook.

They are showcased in the demo notebook.

Overview

To run a given application all you need is to call the associated app.py:

python psaiops/compose/contrast/app.py

All the apps run with the model gpt-oss-20b by default so it is highly recommanded to use a GPU.

Some of the apps are specific to gpt-oss-20b but most can be used with another model. You can look at the section __main__ at the bottom of the file app.py for more details on the setup.

Apps

Contrastive Steering

A straightforward implementation of the technique contrastive activation addition is available in psaiops.compose.contrast.app.

Latent Maths

Pushing the idea of CAA further, psaiops.compose.maths.app allows to compose several prompts in the latent space with maths operators.

Like CAA you can do the difference between prompts, but also multiply, project, average, etc.

Dataset Combination

The app psaiops.combine.app allows to draw from several datasets to form new samples and datasets.

It is useful to create pairs of prompts and form specific latent directions with the contrastive steering technique.

Debugging And Scoring

To support the creation of apps that operate in the latent space, I've used several tools that allow to view the internals of the models.

In particular, you can take apart LLM generated text from human text:

It is using techniques scattered over several other apps that:

  • use a LLM as critic to estimate how surprising each token is
  • score the input tokens according to the attention they get during the generation
  • view the expert logits and associate the routing with the input tokens
  • view the flow of residuals and assess the contribution of the layers to the final output

Credits

The "de-generate" samples include documents from the LLM internals thanks to:

License

Licensed under the AGPLv3.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psaiops-0.12.3.tar.gz (369.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

psaiops-0.12.3-py3-none-any.whl (398.5 kB view details)

Uploaded Python 3

File details

Details for the file psaiops-0.12.3.tar.gz.

File metadata

  • Download URL: psaiops-0.12.3.tar.gz
  • Upload date:
  • Size: 369.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for psaiops-0.12.3.tar.gz
Algorithm Hash digest
SHA256 afa30cbe6d1df1787cd83c846409415405b4c00f0deaa2e4e8a30e5f83e57e4f
MD5 b2b359f8b5d25027a497f71a232be7b0
BLAKE2b-256 bffa4cf6c3300b0da57322dd47bcd23547cff0d8573c82e3b2b19197d1c9d29c

See more details on using hashes here.

File details

Details for the file psaiops-0.12.3-py3-none-any.whl.

File metadata

  • Download URL: psaiops-0.12.3-py3-none-any.whl
  • Upload date:
  • Size: 398.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for psaiops-0.12.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ff060e104f090e6f9a375a6f3c6cdb243d73e3dd34c1e2e9038dfec906327eb3
MD5 c1f7ee62ee543309c1eab1ba8e5450ff
BLAKE2b-256 6510bbceedd10d8f9fc951b119ef590c2782be264dbb990afd1ee5f13cfd2ad1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page