semvec/pypi-packages huggingface dataset:
simple-transformer 0.0.1
A simple and modular implementation of the Transformer model in PyTorch


# Simple Transformer

A simple and modular implementation of the Transformer model in PyTorch. This package provides an intuitive interface to build Transformer models for a variety of NLP tasks like translation, summarization, and more.

---

## 🌟 Features

- **Encoder**, **Decoder**, and **Self-Attention** layers implemented.
- Highly **customizable** architecture (e.g., number of layers, attention heads, embedding size).
- Supports **Masked** and **Unmasked** attention mechanisms.
- Easy to **integrate** and **extend** for different use cases.

---

## 🚀 Installation

### Via pip

You can install the package directly from PyPI:

```bash
pip install simple-transformer
```

### From Source

Alternatively, clone the repository and install it locally:

```bash
git clone https://github.com/nullHawk/simple-transformer.git
cd simple-transformer
pip install .
```

---

## 📝 Usage

### Basic Transformer Model

Here's how you can use the basic Transformer model in your project:

```python
import torch
from simple_transformer import Transformer

# Define input parameters
src_vocab_size = 10
trg_vocab_size = 10
src_pad_idx = 0
trg_pad_idx = 0

# Initialize the Transformer model
model = Transformer(
    src_vocab_size=src_vocab_size,
    trg_vocab_size=trg_vocab_size,
    src_pad_idx=src_pad_idx,
    trg_pad_idx=trg_pad_idx,
)

# Example input (batch_size=2, sequence_length=9)
src = torch.tensor([[1, 5, 6, 4, 3, 9, 5, 2, 0], [1, 8, 7, 3, 4, 5, 6, 7, 2]])
trg = torch.tensor([[1, 7, 4, 3, 5, 9, 2, 0], [1, 5, 6, 2, 4, 7, 6, 2]])

# Forward pass through the Transformer model
out = model(src, trg[:, :-1])
print(out.shape)
```

---

## 🔧 Components

- **Encoder**: Processes the source sequence, extracting context information.
- **Decoder**: Generates the target sequence based on the encoded input.
- **Self-Attention**: Enables each word in a sequence to focus on other words in the same sequence.
- **Transformer**: The central model combining the encoder and decoder for sequence-to-sequence tasks.

---

## 📦 Requirements

- Python >= 3.7
- PyTorch >= 1.9.0

---

## 📄 License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

---

## 🙏 Acknowledgements

- This package is inspired by the [original Transformer model](https://arxiv.org/abs/1706.03762).

---

By adjusting the structure and including headers for each section, the README is now cleaner and more visually appealing. This layout should enhance readability and user experience when browsing through your GitHub repository!
ekcommon 1.0.2
Common hacks in python.

# common-py

My common Python hacks

## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [Contributing](#contributing)
- [License](#license)

## Installation
To install the required dependencies, use:
```bash
pip install ekcommon  
```
To use: 
```
from ekcommon import *
```
or 
```
from commonpy import * 
```


## Usage

### Example 1: Handling Exceptions
```python
from commonpy.simpleexceptioncontext import SimpleExceptionContext

callback = lambda e: self._eng.statusChanges.emit(f'Exception in processing {e}')
with SimpleExceptionContext('exception in processing',callback=callback):
    ret=self.process_internal(ls)
    logging.debug(f"process end {ret}")
    return ret

```
In this example , a callback is called when the exception occurs. 


### Example 2: Exception Handling with Decorators
```python

@simple_exception_handling(err_description='error in get_symbol_history', return_succ=(None, []), never_throw=True)
@excp_handler(polygon.exceptions.BadResponse, handler=excphandler)
def get_symbol_history(sym, startdate, enddate, iscrypto=False):
    # Your code to fetch symbol history here
    pass 
```
### Example 3: Date and Time Utilities

```python
from commonpy import localize_it, unlocalize_it
import datetime

dt = datetime.datetime.now()
localized_dt = localize_it(dt)
unlocalized_dt = unlocalize_it(localized_dt)
```
## Features
- **SimpleExceptionContext**: Context manager for handling exceptions with customizable logging and traceback formatting.
- **Date and Time Utilities**: Functions to localize and unlocalize datetime objects.
- **Functional Helpers**: Various lambda functions for filtering dictionaries and mapping lists.

## Contributing
Contributions are welcome! Please fork this repository and submit a pull request.

## License
This project is licensed under the MIT License.