Edit model card

Query

from vllm import LLM, SamplingParams
from transformers import AutoTokenizer, pipeline

BASE_MODEL = "sh2orc/llama-3-korean-8b-awq"

llm = LLM(model=BASE_MODEL)

tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = 'right'

instruction = 'ํŒŒ์ด์ฌ merge sort ์ฝ”๋“œ์™€ ์ž์„ธํ•œ ์„ค๋ช…๋„ ๊ฐ™์ด ์ œ์‹œํ•ด์ค˜'

messages = [
    {
      "role": "system",
      "content": "๋‹น์‹ ์€ ํ›Œ๋ฅญํ•œ AI ๋น„์„œ์ž…๋‹ˆ๋‹ค. ์งง์€ ๋‹ต๋ณ€์„ ์ œ์‹œํ•˜๊ณ , ๋‹ค์Œ์œผ๋กœ ์ƒ์„ธ ์„ค๋ช…์„ ํ•ด์ฃผ์„ธ์š”. You are a great AI assistant. Give a short answer, then elaborate. "
    },
    {
      "role": "user",
      "content": instruction
    }, 
]

prompt_message = tokenizer.apply_chat_template(
        messages, 
        tokenize=False, 
        add_generation_prompt=True,
)

eos_token_id = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]

outputs = llm.generate(prompt_message, SamplingParams(stop_token_ids=eos_token_id, temperature=0.8, top_p=0.95,max_tokens=2048))

for output in outputs:
    propt = output.prompt
    generated_text = output.outputs[0].text
    print(generated_text)

Result

Merge Sort๋Š” ๋ฐฐ์—ด์„ ๋‘˜๋กœ ๋‚˜๋ˆˆ ๋’ค, ์žฌ๊ท€์ ์œผ๋กœ ์ •๋ ฌ๋œ ๋‘ ๊ฐœ๋ฅผ ํ•ฉํ•˜์—ฌ ์ •๋ ฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ํŒŒ์ด์ฌ์œผ๋กœ ๊ตฌํ˜„ํ•œ Merge Sort ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

```python
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    left = arr[:mid]
    right = arr[mid:]

    left = merge_sort(left)
    right = merge_sort(right)

    return merge(left, right)

def merge(left, right):
    result = []
    i = 0
    j = 0

    while i < len(left) and j < len(right):
        if left[i] < right[j]:
            result.append(left[i])
            i += 1
        else:
            result.append(right[j])
            j += 1

    while i < len(left):
        result.append(left[i])
        i += 1

    while j < len(right):
        result.append(right[j])
        j += 1

    return result

arr = [4, 3, 2, 8, 6, 1, 5, 7, 3, 2, 1]
result = merge_sort(arr)
print(result)
```

์œ„ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ์ถœ๋ ฅ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

```
[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]
```

Merge Sort๋ฅผ ์ž์„ธํžˆ ์„ค๋ช…ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

1. ์ •์˜: Merge Sort๋Š” ๋ฐฐ์—ด์„ ๋‘ ๊ฐœ์˜ ๋ถ€๋ถ„ ๋ฐฐ์—ด์œผ๋กœ ๋‚˜๋ˆˆ ๋’ค, ์žฌ๊ท€์ ์œผ๋กœ ์ •๋ ฌ๋œ ๋‘ ๊ฐœ๋ฅผ ํ•ฉํ•˜์—ฌ ์ •๋ ฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค.

2. ๋™์ž‘: Merge Sort๋Š” ๋ฐฐ์—ด์„ ๋ถ„ํ• ํ•˜์—ฌ ๋‘ ๊ฐœ์˜ ๋ถ€๋ถ„ ๋ฐฐ์—ด์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๊ทธ ํ›„, ์žฌ๊ท€์ ์œผ๋กœ ์ •๋ ฌ๋œ ๋‘ ๊ฐœ๋ฅผ ํ•ฉํ•˜์—ฌ ์ •๋ ฌ๋œ ๊ฒฐ๊ณผ๋ฅผ ์–ป์Šต๋‹ˆ๋‹ค.

3. ์‹œ๊ฐ„ ๋ณต์žก๋„: Merge Sort์˜ ์‹œ๊ฐ„ ๋ณต์žก๋„๋Š” O(n log n)์ด๋ฉฐ, ์ด๋Š” ๋ฐฐ์—ด์˜ ์š”์†Œ๋ฅผ ์žฌ๊ท€์ ์œผ๋กœ ๋ถ„ํ• ํ•˜๊ณ  ์กฐํ•ฉํ•˜๋Š” ๊ณผ์ •์—์„œ ๋ฐœ์ƒํ•˜๋Š” ๋น„๊ต ๋ฐ ์ด๋™์˜ ์ˆ˜๋ฅผ ๊ณ ๋ คํ•ฉ๋‹ˆ๋‹ค.

4. ์žฅ๋‹จ์ : Merge Sort๋Š” ์•ˆ์ •์ ์ธ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ, ๋ฐฐ์—ด์˜ ์›์†Œ๋ฅผ ๋น„ํ™œ์„ฑํ™” ์œ ์ง€ํ•˜๋ฉฐ ์ •๋ ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋ฐฐ์—ด์˜ ์›์†Œ๊ฐ€ ๋งŽ์€ ๊ฒฝ์šฐ, ์žฌ๊ท€์ ์œผ๋กœ ๋ถ„ํ• ๋œ ๋ถ€๋ถ„ ๋ฐฐ์—ด์˜ ์ˆ˜๋ฅผ ์ œํ•œํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์‹œ๊ฐ„ ๋ณต์žก๋„๊ฐ€ ๋†’์•„์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ, Merge Sort๋Š” ์ •๋ ฌ์„ ์›ํ•  ๊ฒฝ์šฐ ์•ˆ์ •์ ์ธ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ๊ณ ๋ คํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
Downloads last month
29
Safetensors
Model size
2.12B params
Tensor type
I32
ยท
FP16
ยท
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.