Rel8ed/cleantech-cls
By Rel8ed · ↓ 3 · ♥ 0 · Updated 2024-04-04
What's in this repo
This page lists the files in Rel8ed/cleantech-cls, including model.onnx, model_quantized.onnx.
- 2 ONNX models (.onnx files)
- 14 files, including 6 .json, 2 .txt, 2 .onnx, 1 .md, 1 .safetensors, 1 .bin
- Last updated 2024-04-04
ONNX files
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
Examples
Here are some examples of how to use this model in Python:
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Rel8ed/cleantech-cls")
model = AutoModelForCausalLM.from_pretrained("Rel8ed/cleantech-cls")
input_prompt = "[METAKEYWORD] innovation, technology, clean energy [TITLE] innovative clean energy solutions [META]" \
"leading provider of clean energy solutions. [ABOUT] we are committed to reducing environmental impact through" \
"cutting-edge clean energy solutions. [HOME] welcome to our website where we explore innovative technologies for a sustainable future."
inputs = tokenizer.encode(input_prompt, return_tensors='pt')
output = model.generate(inputs, max_length=50, num_return_sequences=5)
print("Generated text:")
for i, output in enumerate(outputs):
print(f"{i+1}: {tokenizer.decode(output, skip_special_tokens=True)}")
Preprocess text
import re
def normalize(s, truncate=100):
# Replace "\n" with " "
s = s.replace("\n", " ")
# Keep only letters (including accented letters) and spaces
s = re.sub(r"[^a-zA-Zà-üÀ-Ü ]", "", s)
# Split the string into words, truncate to the first 100 words, and join back into a string
words = s.split()
truncated = words[:truncate]
s = " ".join(truncated)
# Remove additional spaces
s = re.sub(r"\s+", " ", s)
return s
def create_full_text(homepageText,metakeywords = "", title = "", meta = "", aboutText = "", truncate_limit=100):
return (
"[METAKEYWORD] " + normalize(metakeywords, truncate=truncate_limit) +
" [TITLE] " + normalize(title, truncate=truncate_limit) +
" [META] " + normalize(meta, truncate=truncate_limit) +
" [ABOUT] " + normalize(aboutText, truncate=truncate_limit) +
# Assuming we want to normalize homepageText with a much higher limit or no truncation
" [HOME] " + normalize(homepageText, truncate=truncate_limit)
).strip()
# Sample raw inputs
metakeywords = "Green Energy, Sustainability"
meta = "Exploring innovative solutions for a sustainable future."
homepageText = "Welcome to our green energy platform where we share insights and innovations..."
aboutText = "We are committed to advancing green energy solutions through research and development."
title = "Green Energy Innovations"
# Applying your preprocessing steps
full_text = create_full_text(metakeywords, title, meta, aboutText, homepageText)
print(full_text)
Simple usage
from transformers import pipeline
import re
model_name_or_path = "Rel8ed/cleantech-cls"
classifier = pipeline('text-classification', model=model_name_or_path, max_length=512)
def normalize(s, truncate=100):
s = s.replace("\n", " ")
s = re.sub(r"[^a-zA-Zà-üÀ-Ü ]", "", s)
words = s.split()
truncated = words[:truncate]
s = " ".join(truncated)
s = re.sub(r"\s+", " ", s)
return s
def create_full_text(homepageText,metakeywords = "", title = "", meta = "", aboutText = "", truncate_limit=100):
return (
"[METAKEYWORD] " + normalize(metakeywords, truncate=truncate_limit) +
" [TITLE] " + normalize(title, truncate=truncate_limit) +
" [META] " + normalize(meta, truncate=truncate_limit) +
" [ABOUT] " + normalize(aboutText, truncate=truncate_limit) +
# Assuming we want to normalize homepageText with a much higher limit or no truncation
" [HOME] " + normalize(homepageText, truncate=truncate_limit)
).strip()
text = "Welcome to our green energy platform where we share insights and innovations"
predictions = classifier(create_full_text(text))
Model info
text-classification
transformers
transformers
onnx
safetensors
bert
text-classification
text-embeddings-inference
endpoints_compatible
region:us
↓ 3
♥ 0
Created: 2024-03-15
Updated: 2024-04-04
View on Hugging FaceFiles (14)
.gitattributes
README.md
added_tokens.json
config.json
eval_results.txt
model.safetensors
model_args.json
onnx/model.onnx
ONNX
onnx/model_quantized.onnx
ONNX
special_tokens_map.json
tokenizer.json
tokenizer_config.json
training_args.bin
vocab.txt
Related models
More from Rel8ed
No other models by this author.