|
|
"""Continue-1-OSS Model Implementation""" |
|
|
|
|
|
from transformers.models.llama.modeling_llama import \ |
|
|
LlamaAttention as _BaseAttention |
|
|
from transformers.models.llama.modeling_llama import \ |
|
|
LlamaDecoderLayer as _BaseDecoderLayer |
|
|
from transformers.models.llama.modeling_llama import \ |
|
|
LlamaForCausalLM as _BaseModel |
|
|
from transformers.models.llama.modeling_llama import LlamaMLP as _BaseMLP |
|
|
from transformers.models.llama.modeling_llama import \ |
|
|
LlamaModel as _BaseTransformer |
|
|
from transformers.models.llama.modeling_llama import \ |
|
|
LlamaRMSNorm as _BaseRMSNorm |
|
|
from transformers.models.llama.modeling_llama import \ |
|
|
LlamaRotaryEmbedding as _BaseRotaryEmbedding |
|
|
|
|
|
from .configuration_continue_oss import Continue1Config |
|
|
|
|
|
|
|
|
|
|
|
class Continue1RMSNorm(_BaseRMSNorm): |
|
|
"""Continue-1-OSS Root Mean Square Layer Normalization""" |
|
|
pass |
|
|
|
|
|
|
|
|
class Continue1RotaryEmbedding(_BaseRotaryEmbedding): |
|
|
"""Continue-1-OSS Rotary Position Embeddings""" |
|
|
pass |
|
|
|
|
|
|
|
|
class Continue1MLP(_BaseMLP): |
|
|
"""Continue-1-OSS MLP (Feed-Forward Network)""" |
|
|
pass |
|
|
|
|
|
|
|
|
class Continue1Attention(_BaseAttention): |
|
|
"""Continue-1-OSS Multi-Head Attention""" |
|
|
pass |
|
|
|
|
|
|
|
|
class Continue1DecoderLayer(_BaseDecoderLayer): |
|
|
"""Continue-1-OSS Transformer Decoder Layer""" |
|
|
pass |
|
|
|
|
|
|
|
|
class Continue1Model(_BaseTransformer): |
|
|
""" |
|
|
Continue-1-OSS Transformer Model |
|
|
|
|
|
Core transformer model without the language modeling head. |
|
|
""" |
|
|
config_class = Continue1Config |
|
|
|
|
|
def __init__(self, config: Continue1Config): |
|
|
super().__init__(config) |
|
|
|
|
|
|
|
|
class Continue1ForCausalLM(_BaseModel): |
|
|
""" |
|
|
Continue-1-OSS Model for Causal Language Modeling |
|
|
|
|
|
Designed by SVECTOR Corporation for high-quality text generation, |
|
|
instruction following, and long-context understanding. |
|
|
|
|
|
Example: |
|
|
```python |
|
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
|
|
|
model = AutoModelForCausalLM.from_pretrained( |
|
|
"SVECTOR-CORPORATION/Continue-1-OSS", |
|
|
trust_remote_code=True |
|
|
) |
|
|
tokenizer = AutoTokenizer.from_pretrained("SVECTOR-CORPORATION/Continue-1-OSS") |
|
|
|
|
|
messages = [{"role": "user", "content": "Hello There!"}] |
|
|
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt") |
|
|
outputs = model.generate(inputs, max_new_tokens=100) |
|
|
``` |
|
|
""" |
|
|
config_class = Continue1Config |
|
|
|
|
|
def __init__(self, config: Continue1Config): |
|
|
super().__init__(config) |
|
|
|