langchain
langchain copied to clipboard
ConversationSymbolicMemory -- LLM Hackathon
LLM Hackathon Series - Langchain & Gen AI
Extends LangChains chains/conversation with a new kind of Memory
class ConversationSymbolicMemory(Memory, BaseModel):
"""Symbolic Memory to elicit one or more formalisms to represent the microworld of the conversation thus far.
Allows for compression of the information in the buffer with the view of explainability,
introduces allowances to later include notion of practical computability in the formalism,
as well as syntax validation as a way of selecting a syntactically valid subset of
multiple strings generated by LLM.
"""
pass
Prompt chaosmagik incantations
_DEFAULT_FORMALISM_TEMPLATE = """Progressively arrive at the mathematical model of a microworld and the formalism for its symbolic description.
Influences:
[Topos Institute](https://topos.site/)
[Institute for Categorical Cybernetics](https://cybercat.institute/)
[Categories for AI](http://cats.for.ai/)
EXAMPLE
Current formalism:
\begin{equation}
E = mc^2 = I = \frac{m\Delta x^2}{2\Delta t^2}
\end{equation}
where $E$ represents energy, $m$ represents mass, $c$ represents the speed of light, $I$ represents information, $\Delta x$ represents the spatial resolution,
and $\Delta t$ represents the temporal resolution.
This equation establishes the equivalence of information, energy, and mass.
New lines of conversation:
Human: Are energy and information related?
General systems theorists often refer to matter, energy and information as fundamental categories. The three concepts—matter, energy and information—are related through scientific laws. Matter and energy relations are more thoroughly understood than relations involving information. At the level of data or signal “difference” is suggested as a more elementary term than “information”.
AI: At the most fundamental level, energy and information are two sides of the same coin. They are both manifestations of the underlying unity of the universe.
New formalism:
\begin{equation}
\mathcal{C} = \langle{M, E, I}, {f:M\to E, g:M\to I, h:E\to I}, \circ\rangle
\end{equation}
\begin{equation}
\mathcal{C} = \langle{O, M, E, I}, {f_O:O\to M, f_M:M\to E, f_E:E\to I}, \circ\rangle
\end{equation}
where $\mathcal{C}$ represents the category for physical relationships among objects, matter, energy, and information, $O$, $M$, $E$, and $I$ are the objects representing the categories, and $f_O$, $f_M$, and $f_E$ are morphisms representing the relationships between the categories.
\begin{equation}
E_t = \sum_{i=1}^{N}m_i\mathbf{v}_i(t)^2
\end{equation}
where $E_t$ represents the total energy of a system of $N$ particles at time $t$, $m_i$ represents the mass of the $i$-th particle, and $\mathbf{v}_i(t)$ represents the velocity vector of the $i$-th particle at time $t$.
END OF EXAMPLE
Current formalism:
{formalism}
New lines of conversation:
{new_lines}
New formalism:"""
@ajasibley this is the PR! 🔝
Here's a shell.nix to get you to the right env:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
python3
poetry
texlive.combined.scheme-full
tree
];
(tree is cool for context of any LLM's you use to aid you in this quest)
Example iteration loop:
Dev
nix-shell
poetry shell
pytest tests/unit_tests/chains/test_conversation.py
Dist:
nix-shell
poetry build
pip install <the build>.whl
closing as stale