Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
JadenFiotto-Kaufman committed Jan 22, 2024
2 parents 2961a04 + c39aaaf commit 1e119fd
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 70 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified docs/.DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions docs/source/_static/css/status.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* .status-container {
background-color: '#F84F31';
} */

.status-body {
color: "white";
}

.accordion-header {
margin: 0 !important;
}
5 changes: 4 additions & 1 deletion docs/source/_templates/ndif_status.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
var statusIcon = document.querySelector('.ndif .fa-circle-check');

fetch("{{ndif_url}}")
.then((response) => {
if (response.status == 200) {
Expand All @@ -15,7 +15,9 @@
spanElement.style.setProperty('color', '#F84F31', 'important');
});
});
var statusIcon = document.querySelector('.ndif .fa-circle-check');
if (statusIcon) {
// not here
statusIcon.classList.replace('fa-circle-check', 'fa-circle-xmark');
}
}
Expand All @@ -26,6 +28,7 @@
spanElement.style.setProperty('color', '#F84F31', 'important');
});
});
var statusIcon = document.querySelector('.ndif .fa-circle-check');
if (statusIcon) {
statusIcon.classList.replace('fa-circle-check', 'fa-circle-xmark');
}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
{
"name": "Status",
"url": "https://discord.gg/6uFJmCSwW7",
"url": "/status",
"icon": "fa-solid fa-circle-check",
"attributes": {"class": "ndif"},
},
Expand Down
43 changes: 42 additions & 1 deletion docs/source/features.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,49 @@
Features
==========

.. .. grid:: 2
.. :gutter: 2
.. .. grid-item-card:: Getting Values
.. :link: notebooks/features/getting.ipynb
.. .. grid-item-card:: Setting Values
.. :link: notebooks/features/setting.ipynb
.. .. grid-item-card:: Applying Operations
.. :link: notebooks/features/operations.ipynb
.. .. grid-item-card:: Applying Modules
.. :link: notebooks/features/modules.ipynb
.. .. grid-item-card:: Cross-Prompt Intervention
.. :link: notebooks/features/cross_prompt.ipynb
.. .. grid-item-card:: Multiple Token Generation
.. :link: notebooks/features/multiple_token.ipynb
.. .. grid-item-card:: Working With Gradients
.. :link: notebooks/features/gradients.ipynb
.. .. grid-item-card:: Remote Execution
.. :link: notebooks/features/remote_execution.ipynb
.. .. grid-item-card:: Token Based Indexing
.. :link: notebooks/features/token_indexing.ipynb
.. toctree::
:maxdepth: 1

notebooks/features/getting.ipynb
notebooks/features/setting.ipynb
notebooks/features/operations.ipynb
Expand All @@ -13,3 +53,4 @@ Features
notebooks/features/gradients.ipynb
notebooks/features/remote_execution.ipynb
notebooks/features/token_indexing.ipynb

4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ nnsight

.. div:: sd-fs-1 sd-font-weight-bold title-bot sd-text-primary image-container

nnsight
NNsight

.. div:: sd-fs-4 sd-font-weight-bold sd-my-0 sub-bot image-container

interpretable neural networks

**nnsight** (/ɛn.saɪt/) is a package for interpreting and manipulating the internals of large models
**NNsight** (/ɛn.saɪt/) is a package for interpreting and manipulating the internals of large models

.. div:: button-group

Expand Down
200 changes: 136 additions & 64 deletions docs/source/status.rst
Original file line number Diff line number Diff line change
@@ -1,77 +1,149 @@
:html_theme.sidebar_secondary.remove:
:sd_hide_title:

status
.. raw:: html

<link rel="stylesheet" href="../_static/css/status.css">
<script>
function autoFormatJsonString(jsonString) {
// Parse the JSON string into an object
let jsonObject = JSON.parse(jsonString);
// Convert the object back into a string with indentation
let prettyPrintedJson = JSON.stringify(jsonObject, null, 2);
// Replace keys in the JSON string with styled spans
prettyPrintedJson = prettyPrintedJson.replace(/"([^"]+)":/g, '<span style="background-color: lightgrey;">"$1":</span>');
// Set the formatted JSON string as the innerHTML of the element
document.getElementById('jsonContainer').innerHTML = `<pre>${prettyPrintedJson}</pre>`;
}
fetch("https://ndif.dev/ping")
.then((response) => {
if (response.status == 200) {
Array.from(document.getElementsByClassName("status-container")).forEach((elm) => {
elm.style.backgroundColor = "#23C552";
Array.from(elm.getElementsByClassName('sd-card-text')).forEach((text) => {
text.textContent = "All Systems Are Operational";
text.style.color = "#FFFFFF";
});
});
console.log('Ping success');
// Nested fetch to ndif.dev/stats
fetch("https://ndif.dev/stats")
.then((statsResponse) => {
if (statsResponse.status == 200) {
statsResponse.json().then((parsed) => {
// Initialize an empty string to accumulate information
let infoString = '';
let index = 0;
let modelSummary = {};
Object.values(parsed).forEach((value) => {
// Create a unique key for each model-config combination
let modelConfigKey = `${value.repo_id}`;
// Check if this model-config combination already exists in the summary
if (modelSummary[modelConfigKey]) {
// Increment the count if it does
modelSummary[modelConfigKey].number_of_copies += 1;
} else {
// Otherwise, add a new entry
modelSummary[modelConfigKey] = {
number_of_copies: 1,
config_string: value.config_json_string
};
}
});
// Now modelSummary contains the consolidated information
console.log(modelSummary);
// Iterate through the JSON dictionary and append information
// Iterate through the modelSummary dictionary and append information
Object.keys(modelSummary).forEach((key) => {
var headingId = 'heading' + (index + 1);
var collapseId = 'collapse' + (index + 1);
const summaryItem = modelSummary[key];
const configJsonString = summaryItem.config_string;
let jsonObject = JSON.parse(configJsonString);
// Convert the object back into a string with indentation
let prettyPrintedJson = JSON.stringify(jsonObject, null, 4);
prettyPrintedJson = prettyPrintedJson.replace(/"([^"]+)":/g, '"<b>$1</b>":');
let huggingFaceLink = `<a href="http://huggingface.co/${key}" target="_blank">HuggingFace Model Repository ↗</a>`;
infoString += `<div class="accordion-item"> <h2 class="accordion-header" id="${headingId}"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#${collapseId}" aria-expanded="false" aria-controls="${collapseId}"> (${summaryItem.number_of_copies}x) ${key} </button> </h2> <div id="${collapseId}" class="accordion-collapse collapse" aria-labelledby="${headingId}" data-bs-parent="#accordionExample"> <div class="accordion-body">${huggingFaceLink}</i> <pre>${prettyPrintedJson}</pre></div> </div> </div>`;
index++;
});
var elm = document.getElementById("accordionHook");
elm.innerHTML = infoString;
console.log('Stats success');
}).catch((jsonError) => {
console.log('JSON parsing error:', jsonError);
});
} else {
console.log('Stats error');
}
})
.catch((statsError) => {
console.log('Stats error');
});
} else {
Array.from(document.getElementsByClassName("status-container")).forEach((elm) => {
elm.style.backgroundColor = "#F84F31";
Array.from(elm.getElementsByClassName('sd-card-text')).forEach((text) => {
text.textContent = "NDIF Is Unavailable";
text.style.color = "#FFFFFF";
});
});
console.log('Ping error');
}
})
.catch((pingError) => {
Array.from(document.getElementsByClassName("status-container")).forEach((elm) => {
elm.style.backgroundColor = "#F84F31";
Array.from(elm.getElementsByClassName('sd-card-text')).forEach((text) => {
text.textContent = "NDIF Is Unavailable";
text.style.color = "#FFFFFF";
});
});
console.error('Ping fetch failed:', pingError);
});
</script>


Status
======



.. toctree::
:maxdepth: 1
:hidden:



.. card::

All Systems Are Operational



.. div:: sd-fs-1 sd-font-weight-bold sd-text-center sd-text-primary sd-mb-5

Key Features

.. grid:: 1 1 2 2
:class-container: features

.. grid-item::

.. div:: features-container

.. image:: _static/images/one.png
:width: 250

.. div::

**Integration**

Pass in a ID from any HuggingFace Transformer repo and access its weights with nnsight.

.. grid-item::

.. div:: features-container

.. image:: _static/images/two.png
:width: 250

.. div::

**Interpretability**

Access the internal gradients and activations at any point or module in a model.
:class-card: status-container

.. grid-item::

.. div:: features-container

.. image:: _static/images/two.png
:width: 250

.. div::

**Intuitive**

Set up a context block and manipulate model internals with only a couple lines of code.

.. grid-item::

.. div:: features-container

.. image:: _static/images/one.png
:width: 250

.. div::

**Interoperable**
All Systems Are Operational

Enable grad and train interventions like LORA or probes on any point in a model.
.. raw:: html

<div class="accordion accordion-flush" id="accordionHook">
</div>
2 changes: 1 addition & 1 deletion docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Tutorials
.. grid-item-card:: Walkthrough
:link: notebooks/walkthrough.ipynb

Main features of the nnsight library.
:bdg-primary:`Main Features`

.. grid-item-card:: IOI Patching
:link: notebooks/tutorials/ioi_patching.ipynb
Expand Down

0 comments on commit 1e119fd

Please sign in to comment.