Coder Social home page Coder Social logo

neelnanda-io / circuitsvis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from transformerlensorg/circuitsvis

0.0 0.0 0.0 7.38 MB

Mechanistic Interpretability Visualizations using React

Home Page: https://alan-cooney.github.io/CircuitsVis/

License: MIT License

JavaScript 0.06% Python 0.36% TypeScript 5.32% Jupyter Notebook 94.23% Dockerfile 0.02%

circuitsvis's Introduction

CircuitsVis

Mechanistic Interpretability visualizations, that work both in both Python (e.g. with Jupyter Lab) and JavaScript (e.g. React or plain HTML).

View them all at https://alan-cooney.github.io/CircuitsVis

Use

Install

Python

pip install circuitsvis

React

yarn add circuitsvis

Add visualizations

You can use any of the components from the demo page. These show the source code for use with React, and for Python you can instead import the function with the same name.

# Python Example
from circuitsvis.tokens import colored_tokens
colored_tokens(["My", "tokens"], [0.123, -0.226])
// React Example
import ColoredTokens from "circuitsvis";

function Example() {
    <ColoredTokens
        tokens=["My", "tokens"]
        values=[0.123, -0.266]
    />
}

Contribute

Development requirements

DevContainer

For a one-click setup of your development environment, this project includes a DevContainer. It can be used locally with VS Code or with GitHub Codespaces.

Manual setup

To create new visualizations you need Node (including yarn) and Python (with Poetry).

Once you have these, you need to install both the Node & Python packages (note that for Python we use the Poetry package management system).

cd react && yarn
cd python && poetry install --with dev

Jupyter install

If you want Jupyter as well, run poetry install --with jupyter or, if this fails due to a PyTorch bug on M1 MacBooks, run poetry run pip install jupyter.

Creating visualizations

React

You'll first want to create the visualisation in React. To do this, you can copy the example from /react/src/examples/Hello.tsx. To view changes whilst editing this (in Storybook), run the following from the /react/ directory:

yarn storybook

Python

This project uses Poetry for package management. To install all rew

Once you've created your visualization in React, you can then create a short function in the Python library to render it. You can see an example in /python/circuitsvis/examples.py.

Note that this example will render from the CDN, unless development mode is specified. Your visualization will only be available on the CDN once it has been released to the latest production version of this library.

Continuous Delivery

When a PR is merged, it will automatically release updated minor versions of the Node and Python libraries.

circuitsvis's People

Contributors

alan-cooney avatar oliverbalfour avatar neelnanda-io avatar nelhage avatar colah avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.