Metadata-Version: 2.1
Name: LangTorch
Version: 0.1.1
Summary: Framework for intuitive LLM application development with tensors.
Home-page: https://github.com/AdamSobieszek/LangTorch
Author: Adam Sobieszek
Author-email: contact@langtorch.org
Keywords: LangTorch,PyTorch,LLM,Language Models,Chat,Chains
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE


# <img src="langtorch_logo.png" width="60" height="60" alt="LangTorch Logo" style="vertical-align: middle;"> LangTorch


LangTorch is a Python package designed to simplify the development of LLM applications by leveraging familiar PyTorch concepts.

## Installation

```bash
pip install langtorch
```

## Overview

LangTorch provides a structured approach to LLM applications, offering:

- **TextTensors**: A unified way to handle prompt templates, completion dictionaries, and chat histories.
- **TextModules**: Building blocks, derived from torch.nn.Module, specifically tailored for text operations and LLM calls both locally and via an API.
- other things that are also better than langchain
## Examples

### TextTensors

Creating and manipulating textual data as tensors:

```python
template = TextTensor([["Summarize {theory} in terms of {framework}"],
                       ["Argue that {framework} can prove {theory}" ]])

template * TextTensor({"theory": "causal inference", 
                    "framework": "thermodynamics" })

# Outputs: [[Summarize causal inference in terms of thermodynamics]
#           [Argue that thermodynamics can prove causal inference ]] 
```

### TextModules

Building sequences of operations on text data:

```python
chain = torch.nn.Sequential(
    TextModule("Calculate this equation: {}"),
    langtorch.methods.CoT,
    GPT4
    TextModule("Is this reasoning correct? {}", activation = GPT4)
)

output = chain(TextTensor(["170*32 =", "4*20 =", "123*45/10 =", "2**10*5 ="]))
```

### Cosine Similarities

Compute similarities between entries:

```python
from langtorch.tt import CosineSimilarity

cos = CosineSimilarity()
similarities = cos(TextTensor([["Yes"], ["No"]]), TextTensor(["1", "0", "Noo", "Yees"]))
```

## Contribute

Your feedback and contributions are valued. Feel free to check out our [contribution guidelines](#).

## License

LangTorch is MIT licensed. See the [LICENSE](#) file for details.
