feat: add pipeline tag, library name, and sample usage (#1)
Browse files- Add pipeline tag, library name, and sample usage (f8c0df49f8d80adf4eadd7b15e824b98dfbeef91)
Co-authored-by: Niels Rogge <[email protected]>
    	
        README.md
    CHANGED
    
    | @@ -1,7 +1,9 @@ | |
| 1 | 
             
            ---
         | 
| 2 | 
            -
            license: apache-2.0
         | 
| 3 | 
             
            base_model:
         | 
| 4 | 
             
            - deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
         | 
|  | |
|  | |
|  | |
| 5 | 
             
            ---
         | 
| 6 |  | 
| 7 | 
             
            # Spiral-DeepSeek-R1-Distill-Qwen-7B
         | 
| @@ -18,6 +20,47 @@ This model is trained with self-play on multi-games (TicTacToe, Kuhn Poker, Simp | |
| 18 |  | 
| 19 | 
             
            <img src="https://raw.githubusercontent.com/spiral-rl/spiral/refs/heads/main/assets/framework.png" width=100%/>
         | 
| 20 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 21 |  | 
| 22 | 
             
            ## Citation
         | 
| 23 |  | 
|  | |
| 1 | 
             
            ---
         | 
|  | |
| 2 | 
             
            base_model:
         | 
| 3 | 
             
            - deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
         | 
| 4 | 
            +
            license: apache-2.0
         | 
| 5 | 
            +
            pipeline_tag: text-generation
         | 
| 6 | 
            +
            library_name: transformers
         | 
| 7 | 
             
            ---
         | 
| 8 |  | 
| 9 | 
             
            # Spiral-DeepSeek-R1-Distill-Qwen-7B
         | 
|  | |
| 20 |  | 
| 21 | 
             
            <img src="https://raw.githubusercontent.com/spiral-rl/spiral/refs/heads/main/assets/framework.png" width=100%/>
         | 
| 22 |  | 
| 23 | 
            +
            ## Usage
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            This model can be easily loaded and used with the `transformers` library.
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            ```python
         | 
| 28 | 
            +
            from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
         | 
| 29 | 
            +
            import torch
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            model_id = "spiral-rl/Spiral-DeepSeek-R1-Distill-Qwen-7B"
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            # Load model and tokenizer
         | 
| 34 | 
            +
            tokenizer = AutoTokenizer.from_pretrained(model_id)
         | 
| 35 | 
            +
            model = AutoModelForCausalLM.from_pretrained(
         | 
| 36 | 
            +
                model_id,
         | 
| 37 | 
            +
                torch_dtype=torch.bfloat16, # or torch.float16 for GPUs that don't support bfloat16
         | 
| 38 | 
            +
                device_map="auto"
         | 
| 39 | 
            +
            )
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            # Create a text generation pipeline
         | 
| 42 | 
            +
            pipe = pipeline(
         | 
| 43 | 
            +
                "text-generation",
         | 
| 44 | 
            +
                model=model,
         | 
| 45 | 
            +
                tokenizer=tokenizer,
         | 
| 46 | 
            +
                max_new_tokens=50,
         | 
| 47 | 
            +
                do_sample=True,
         | 
| 48 | 
            +
                temperature=0.7,
         | 
| 49 | 
            +
                top_k=50,
         | 
| 50 | 
            +
                top_p=0.95
         | 
| 51 | 
            +
            )
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            # Define a chat message
         | 
| 54 | 
            +
            messages = [
         | 
| 55 | 
            +
                {"role": "user", "content": "What is the capital of France?"}
         | 
| 56 | 
            +
            ]
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            # Generate text
         | 
| 59 | 
            +
            output = pipe(messages)
         | 
| 60 | 
            +
            print(output[0]['generated_text'])
         | 
| 61 | 
            +
            ```
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            For more advanced usage, including training and evaluation with the SPIRAL framework, please refer to the [GitHub repository](https://github.com/spiral-rl/spiral).
         | 
| 64 |  | 
| 65 | 
             
            ## Citation
         | 
| 66 |  | 

 
		