AI SeedbankHelp preserve open and free AI for humanity's future

← All models

daekeun-ml_koelectra-small-v3-nsmc

daekeun-ml · View on Hugging Face ↗

Get this model

Download TorrentMagnet Link

Seeders: · Leechers:

Model card

The complete upstream card, rendered from this payload's README.md — the same hash-verified bytes the torrent distributes. Images and off-site links are removed; the original card on Hugging Face carries them.


language:

  • ko tags:
  • classification license: mit datasets:
  • nsmc widget:
  • text: "불후의 명작입니다! 이렇게 감동적인 내용은 처음이에요" example_title: "Positive"
  • text: "시간이 정말 아깝습니다. 10점 만점에 1점도 아까워요.." example_title: "Negative" metrics:
  • accuracy
  • f1
  • precision
  • recall- accuracy

Sentiment Binary Classification (fine-tuning with KoELECTRA-Small-v3 model and Naver Sentiment Movie Corpus dataset)

Usage (Amazon SageMaker inference applicable)

It uses the interface of the SageMaker Inference Toolkit as is, so it can be easily deployed to SageMaker Endpoint.

inference_nsmc.py

import json
import sys
import logging
import torch
from torch import nn
from transformers import ElectraConfig
from transformers import ElectraModel, AutoTokenizer, ElectraTokenizer, ElectraForSequenceClassification

logging.basicConfig(
    level=logging.INFO, 
    format='[{%(filename)s:%(lineno)d} %(levelname)s - %(message)s',
    handlers=[
        logging.FileHandler(filename='tmp.log'),
        logging.StreamHandler(sys.stdout)
    ]
)
logger = logging.getLogger(__name__)

max_seq_length = 128
classes = ['Neg', 'Pos']

tokenizer = AutoTokenizer.from_pretrained("daekeun-ml/koelectra-small-v3-nsmc")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")


def model_fn(model_path=None):
    ####
    # If you have your own trained model
    # Huggingface pre-trained model: 'monologg/koelectra-small-v3-discriminator'
    ####
    #config = ElectraConfig.from_json_file(f'{model_path}/config.json')
    #model = ElectraForSequenceClassification.from_pretrained(f'{model_path}/model.pth', config=config)
    
    # Download model from the Huggingface hub
    model = ElectraForSequenceClassification.from_pretrained('daekeun-ml/koelectra-small-v3-nsmc')   
    model.to(device)
    return model


def input_fn(input_data, content_type="application/jsonlines"): 
    data_str = input_data.decode("utf-8")
    jsonlines = data_str.split("\n")
    transformed_inputs = []

    for jsonline in jsonlines:
        text = json.loads(jsonline)["text"][0]
        logger.info("input text: {}".format(text))          
        encode_plus_token = tokenizer.encode_plus(
            text,
            max_length=max_seq_length,
            add_special_tokens=True,
            return_token_type_ids=False,
            padding="max_length",
            return_attention_mask=True,
            return_tensors="pt",
            truncation=True,
        )
        transformed_inputs.append(encode_plus_token)
        
    return transformed_inputs


def predict_fn(transformed_inputs, model):
    predicted_classes = []
    
    for data in transformed_inputs:
        data = data.to(device)
        output = model(**data)

        softmax_fn = nn.Softmax(dim=1)
        softmax_output = softmax_fn(output[0])
        _, prediction = torch.max(softmax_output, dim=1)

        predicted_class_idx = prediction.item()
        predicted_class = classes[predicted_class_idx]
        score = softmax_output[0][predicted_class_idx]
        logger.info("predicted_class: {}".format(predicted_class))

        prediction_dict = {}
        prediction_dict["predicted_label"] = predicted_class
        prediction_dict['score'] = score.cpu().detach().numpy().tolist()

        jsonline = json.dumps(prediction_dict)
        logger.info("jsonline: {}".format(jsonline))        
        predicted_classes.append(jsonline)

    predicted_classes_jsonlines = "\n".join(predicted_classes)
    return predicted_classes_jsonlines


def output_fn(outputs, accept="application/jsonlines"):
    return outputs, accept

test.py

>>> from inference_nsmc import model_fn, input_fn, predict_fn, output_fn
>>> with open('samples/nsmc.txt', mode='rb') as file:
>>>     model_input_data = file.read()
>>> model = model_fn()
>>> transformed_inputs = input_fn(model_input_data)
>>> predicted_classes_jsonlines = predict_fn(transformed_inputs, model)
>>> model_outputs = output_fn(predicted_classes_jsonlines)
>>> print(model_outputs[0])    
   
[{inference_nsmc.py:47} INFO - input text: 이 영화는 최고의 영화입니다
[{inference_nsmc.py:47} INFO - input text: 최악이에요. 배우의 연기력도 좋지 않고 내용도 너무 허접합니다
[{inference_nsmc.py:77} INFO - predicted_class: Pos
[{inference_nsmc.py:84} INFO - jsonline: {"predicted_label": "Pos", "score": 0.9619030952453613}
[{inference_nsmc.py:77} INFO - predicted_class: Neg
[{inference_nsmc.py:84} INFO - jsonline: {"predicted_label": "Neg", "score": 0.9994170665740967}
{"predicted_label": "Pos", "score": 0.9619030952453613}
{"predicted_label": "Neg", "score": 0.9994170665740967}

Sample data (samples/nsmc.txt)

{"text": ["이 영화는 최고의 영화입니다"]}
{"text": ["최악이에요. 배우의 연기력도 좋지 않고 내용도 너무 허접합니다"]}

References

  • KoELECTRA: https://github.com/monologg/KoELECTRA
  • Naver Sentiment Movie Corpus Dataset: https://github.com/e9t/nsmc

Magnet link

Opens the swarm directly in your torrent client — no file download needed. Copy-paste works too:

magnet:?xt=urn:btih:a413fe8846cb1f4e94957cf0cf429626a69e26d8&dn=daekeun-ml_koelectra-small-v3-nsmc

Open magnet in torrent client · infohash a413fe8846cb1f4e94957cf0cf429626a69e26d8

Files & hashes

PathSizesha1sha256
README.md5.0 KB (5,095 B)391cb72bb9855e38ecb7a634859c225532debdb26438dcd28b9c530207e93d1fba7851308bbb1ea0d0e4d4aecc76e9abe0fee288
config.json914 B (914 B)b423bc437b8c02693816c52f9fe4dec272b2011c74faecc0ab34bbbc21746005b9c30a17c0c6882fb5d1f9bfe8001cdca6866cd6
model.safetensors53.9 MB (56,518,128 B)79a14cb6f027a289a98105008c188344113fb710012a5926dcfe2d0b1caf17ef79963097838f693ce12fad2a27d8802bd3fdec28
pytorch_model.bin54.0 MB (56,578,459 B)a692732633b1a5bbdeeb8c2435c4d46a8677143f756dde30d2f35d35766d9c856f43fb669ba00d22df858349b30e6ab9f8cce62d
special_tokens_map.json112 B (112 B)e7b0375001f109a6b8873d756ad4f7bbb15fbaa5303df45a03609e4ead04bc3dc1536d0ab19b5358db685b6f3da123d05ec200e3
tokenizer.json521.2 KB (533,711 B)63a7aa575891acb48c0a6f1ec28293215abddc38db6f152b710372fb53b07d27aa7665ff1a2efb308250b69373530caf5da0b9f2
tokenizer_config.json414 B (414 B)8f9333e85573ffbf2e66ec95074385129e38d5833097b7a6b02bd00db740f13aa6625b31dc1276d385b03c408348c95a5f71d848
training_args.bin1.5 KB (1,519 B)8d093b89b0e0e99f5ffa7161819f42ef61dc342e6f8238eebcbe012157220c4c1647c4cff2d3e0e99195a24e406e0099b4f46f5d
vocab.txt257.2 KB (263,327 B)6033c2fd2b9266df1abb47ebe2704163eebbc4d76e886927dfcecd22029b1ba80c10a1374740259c1067fc3a28d964b7ae2d55a7

Cite this release

Canonical URL
https://aiseedbank.org/models/daekeun-ml_koelectra-small-v3-nsmc/
Slug
daekeun-ml_koelectra-small-v3-nsmc
Infohash
a413fe8846cb1f4e94957cf0cf429626a69e26d8
License
mit
Signing key fingerprint
85a3b32c3712427b

Every file carries a locally computed sha256 — verify a download against the signed sums: daekeun-ml_koelectra-small-v3-nsmc.SHA256SUMS (+ minisign signature).

Provenance

Upstream repositorydaekeun-ml/koelectra-small-v3-nsmc
Revision (pinned)d1c0233fc013ae8bd879d7b61f2bec69aa3af4c9
Fetched at2026-09-03T21:25:32Z
License at fetchmit
Snapshot toolhuggingface · seedbank 0.1.0

Trackers

✓ verified · rehash-vs-hf-metadata at 2026-09-03T21:25:37Z

mit108.6 MB (113,901,679 bytes)transformerspytorchsafetensorselectratext-classificationclassificationendpoints_compatible1 language (ko)