Xsmos commited on
Commit
24a6403
·
verified ·
1 Parent(s): 989ce21

Cleanup: Remove legacy files

Browse files
__init__.py DELETED
File without changes
example.ipynb DELETED
@@ -1,41 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "07604227",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": []
10
- },
11
- {
12
- "cell_type": "code",
13
- "execution_count": null,
14
- "id": "9882fd75",
15
- "metadata": {},
16
- "outputs": [],
17
- "source": []
18
- }
19
- ],
20
- "metadata": {
21
- "kernelspec": {
22
- "display_name": "fsdp",
23
- "language": "python",
24
- "name": "python3"
25
- },
26
- "language_info": {
27
- "codemirror_mode": {
28
- "name": "ipython",
29
- "version": 3
30
- },
31
- "file_extension": ".py",
32
- "mimetype": "text/x-python",
33
- "name": "python",
34
- "nbconvert_exporter": "python",
35
- "pygments_lexer": "ipython3",
36
- "version": "3.12.5"
37
- }
38
- },
39
- "nbformat": 4,
40
- "nbformat_minor": 5
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
utils/__init__.py DELETED
File without changes
utils/masked_data_modeling_loss.py DELETED
@@ -1,24 +0,0 @@
1
- import torch
2
- from einops import rearrange
3
- '''
4
- Simple class to do all MLM sort of loss operations in one place
5
- '''
6
- class MaskedDataLossWithSoftmax(torch.nn.Module):
7
- def __init__(self, ignore: int=-100, reduction: str='mean', weight=None):
8
- super(MaskedDataLossWithSoftmax, self).__init__()
9
- self.loss = torch.nn.CrossEntropyLoss(ignore_index=-100,
10
- reduction=reduction,
11
- weight=weight)
12
-
13
- def __call__(self, logits: torch.Tensor,
14
- labels: torch.Tensor
15
- )-> torch.Tensor:
16
- """
17
- Logits: [batch_size, seq_len, vocab_size]; without softmax applied
18
- Labels should have -100 for all indices that are not part of masked tokens
19
-
20
- """
21
- logits = rearrange(logits, 'b s v -> b v s')
22
- loss = self.loss(logits, labels)
23
-
24
- return loss
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
utils/yaml_util.py DELETED
@@ -1,24 +0,0 @@
1
- import yaml
2
- class MyLoader(yaml.SafeLoader):
3
- # returns
4
- def construct_mapping(self, *args, **kwargs):
5
- super().add_constructor(None, construct_undefined)
6
- # when loading we want to skip keys that require construction,
7
- mapping = super().construct_mapping(*args, **kwargs)
8
-
9
- return mapping
10
- import typing
11
- class Tagged(typing.NamedTuple):
12
- tag: str
13
- value: object
14
-
15
- def construct_undefined(self, node):
16
- if isinstance(node, yaml.nodes.ScalarNode):
17
- value = self.construct_scalar(node)
18
- elif isinstance(node, yaml.nodes.SequenceNode):
19
- value = self.construct_sequence(node)
20
- elif isinstance(node, yaml.nodes.MappingNode):
21
- value = self.construct_mapping(node)
22
- else:
23
- assert False, f"unexpected node: {node!r}"
24
- return Tagged(node.tag, value)