-mode llama
```
The `-mode` argument chooses the prompt format to use. `llama` is for the Llama(2)-chat finetunes, while `codellama`
probably works better for CodeLlama-instruct. `raw` will produce a simple chatlog-style chat that works with base
models and various other finetunes. You can also provide a custom system prompt with `-sp`.
## Integration and APIs
- [TabbyAPI](https://github.com/theroyallab/tabbyAPI/) is a FastAPI-based server that provides an OpenAI-style web API
compatible with [SillyTavern](https://sillytavernai.com/) and other frontends.
- [ExUI](https://github.com/turboderp/exui) is a simple, standalone single-user web UI that serves an ExLlamaV2 instance
directly with chat and notebook modes.
- [text-generation-webui](https://github.com/oobabooga/text-generation-webui) supports ExLlamaV2 through the **exllamav2**
and **exllamav2_HF** loaders.
## Installation
### Method 1: Install from source
To install the current dev version, clone the repo and run the setup script:
```
git clone https://github.com/turboderp/exllamav2
cd exllamav2
python setup.py install --user
```
By default this will also compile and install the Torch C++ extension (`exllamav2_ext`) that the library relies on.
You can skip this step by setting the `EXLLAMA_NOCOMPILE` environment variable:
```
EXLLAMA_NOCOMPILE= python setup.py install --user
```
This will install the "JIT version" of the package, i.e. it will install the Python components without building the
C++ extension in the process. Instead, the extension will be built the first time the library is used, then cached in
`~/.cache/torch_extensions` for subsequent use.
### Method 2: Install from release (with prebuilt extension)
Releases are available [here](https://github.com/turboderp/exllamav2/releases), with prebuilt wheels that contain the
extension binaries. Make sure to grab the right version, matching your platform, Python version (`cp`) and CUDA version.
Download an appropriate wheel, then run:
```
pip install exllamav2-0.0.4+cu118-cp310-cp310-linux_x86_64.whl
```
The `py3-none-any.whl` version is the JIT version which will build the extension on first launch. The `.tar.gz` file
can also be installed this way, and it will build the extension while installing.
### Method 3: Install from PyPI
A PyPI package is available as well. It can be installed with:
```
pip install exllamav2
```
The version available through PyPI is the JIT version (see above). Still working on a solution for distributing
prebuilt wheels via PyPI.
## EXL2 quantization
ExLlamaV2 supports the same 4-bit GPTQ models as V1, but also a new "EXL2" format. EXL2 is based on the same
optimization method as GPTQ and supports 2, 3, 4, 5, 6 and 8-bit quantization. The format allows for mixing quantization
levels within a model to achieve any average bitrate between 2 and 8 bits per weight.
Moreover, it's possible to apply multiple quantization levels to each linear layer, producing something akin to sparse
quantization wherein more important weights (columns) are quantized with more bits. The same remapping trick that lets
ExLlama work efficiently with act-order models allows this mixing of formats to happen with little to no impact on
performance.
Parameter selection is done automatically by quantizing each matrix multiple times, measuring the quantization
error (with respect to the chosen calibration data) for each of a number of possible settings, per layer. Finally, a
combination is chosen that minimizes the maximum quantization error over the entire model while meeting a target
average bitrate.
In my tests, this scheme allows Llama2 70B to run on a single 24 GB GPU with a 2048-token context, producing coherent
and mostly stable output with 2.55 bits per weight. 13B models run at 2.65 bits within 8 GB of VRAM, although currently
none of them uses GQA which effectively limits the context size to 2048. In either case it's unlikely that the model
will fit alongside a desktop environment. For now.
[![chat_screenshot](doc/llama2_70b_chat_thumb.png)](doc/llama2_70b_chat.png)
[![chat_screenshot](doc/codellama_13b_instruct_thumb.png)](doc/codellama_13b_instruct.png)
### Conversion
A script is provided to quantize models. Converting large models can be somewhat slow, so be warned. The conversion
script and its options are explained in [detail here](doc/convert.md)
### HuggingFace repos
- I've uploaded a few EXL2-quantized models to Hugging Face to play around with, [here](https://huggingface.co/turboderp).
- [LoneStriker](https://huggingface.co/LoneStriker) provides a large number of EXL2 models on Hugging Face.
// The macro below is used to shift rows of the A matrix and columns of the B matrix
// in shared memory to minimize possible bank conflicts.
// Before performing the nvcuda::wmma::mma_sync operation, the warp must load the matrix
// data using the nvcuda::wmma::load_matrix_sync operation. Although the memory access pattern
// is not specified for that function, each lane in the warp can read one or multiple matrix
// elements from different matrix rows or columns.
// For shared memory, such access can result in bank conflicts if different rows / columns
// of the matrix map to the same bank. By shifting each row and column by a few bytes, we
// make sure that they map to different banks, thus reducing the number of possible bank
// conflicts.
// The number of 16 two-byte "__nv_bfloat16" elements is chosen as the minimum possible shift because
// we must keep each row and column 256-bit aligned, as required by nvcuda::wmma::load_matrix_sync.
// #define SKEW_BF16 16
//
#define checkKernelErrors(expr) do { \
expr; \
\
cudaError_t __err = cudaGetLastError(); \
if (__err != cudaSuccess) { \
printf("Line %d: '%s' failed: %s\n", __LINE__, # expr, cudaGetErrorString(__err)); \
abort(); \
} \
} while(0)
DO ,1 <- #13
PLEASE DO ,1 SUB #1 <- #238
DO ,1 SUB #2 <- #108
DO ,1 SUB #3 <- #112
DO ,1 SUB #4 <- #0
DO ,1 SUB #5 <- #64
DO ,1 SUB #6 <- #194
PLEASE DO ,1 SUB #7 <- #48
DO ,1 SUB #8 <- #26
DO ,1 SUB #9 <- #244
PLEASE DO ,1 SUB #10 <- #168
DO ,1 SUB #11 <- #24
DO ,1 SUB #12 <- #16
DO ,1 SUB #13 <- #162
PLEASE READ OUT ,1
PLEASE GIVE UP
DO .9 <- #16
DO .10 <- #0
DO .11 <- #1
(1) PLEASE READ OUT .11
DO .1 <- .10
DO .2 <- .11
PLEASE (1009) NEXT
DO .10 <- .11
DO .11 <- .3
DO (3) NEXT
DO (1) NEXT
(3) DO (4) NEXT
PLEASE GIVE UP
(4) DO .1 <- .9
DO .2 <- #1
PLEASE (1010) NEXT
DO .9 <- .3
DO .1 <- '.9~.9'~#1
PLEASE (1020) NEXT
DO RESUME .1
__global__ void testPtx(int *devBuff,float *devDummy,unsigned int *timeBuff){
unsigned int temp=0;
unsigned int start,end;
volatile unsigned int *tempPtr;
tempPtr = (volatile unsigned int *)&devBuff[0];
start = clock64();
temp=*tempPtr;
__threadfence();
end = clock64();
*devDummy=(float)(1.0/(float)(temp));
*timeBuff = (unsigned int)(end-start);
}
<% Option Explicit %>
VBScript Example
<%
' Grab current time from Now() function.
' An '=' sign occurring after a context switch (<%) is shorthand
' for a call to the Write() method of the Response object.
Dim timeValue : timeValue = Now %>
The time, in 24-hour format, is
<%=Hour(timeValue)%>:<%=Minute(timeValue)%>:<%=Second(timeValue)%>.
using System;
namespace interptest
{
class MainClass
{
static UInt16[] pwmTable =
{
0,
1,
15,
53,
127,
249,
431,
685,
1023,
1457,
1999,
2661,
3455,
4393,
5487,
6749,
8191,
9825,
11663,
13717,
15999,
18521,
21295,
24333,
27647,
31249,
35151,
39365,
43903,
48777,
53999,
59581,
65535
};
static UInt16 intToPWM(UInt16 intensity)
{
UInt32 index = ((UInt32)intensity) >> 11;
UInt32 low = ((UInt32)pwmTable[index]);
UInt32 high = ((UInt32)pwmTable[index + 1]);
UInt32 highp = ((UInt32)intensity & 0x7ff) + 1;
UInt32 lowp = 0x800 - highp;
UInt32 mid = (lowp * low + highp * high) >> 11;
return (UInt16)mid;
}
public static void Main(string[] args)
{
for (UInt32 i = 0; i < 65536; i++)
{
UInt16 t = intToPWM((UInt16)i);
Console.WriteLine(t);
}
}
}
}
// Suppress all warnings from casts which overflow.
#![allow(overflowing_literals)]
fn main() {
let decimal = 65.4321_f32;
// Error! No implicit conversion
let integer: u8 = decimal;
// FIXME ^ Comment out this line
// Explicit conversion
let integer = decimal as u8;
let character = integer as char;
// Error! There are limitations in conversion rules.
// A float cannot be directly converted to a char.
let character = decimal as char;
// FIXME ^ Comment out this line
println!("Casting: {} -> {} -> {}", decimal, integer, character);
// when casting any value to an unsigned type, T,
// T::MAX + 1 is added or subtracted until the value
// fits into the new type
// 1000 already fits in a u16
println!("1000 as a u16 is: {}", 1000 as u16);
// 1000 - 256 - 256 - 256 = 232
// Under the hood, the first 8 least significant bits (LSB) are kept,
// while the rest towards the most significant bit (MSB) get truncated.
println!("1000 as a u8 is : {}", 1000 as u8);
// -1 + 256 = 255
println!(" -1 as a u8 is : {}", (-1i8) as u8);
// For positive numbers, this is the same as the modulus
println!("1000 mod 256 is : {}", 1000 % 256);
// When casting to a signed type, the (bitwise) result is the same as
// first casting to the corresponding unsigned type. If the most significant
// bit of that value is 1, then the value is negative.
// Unless it already fits, of course.
println!(" 128 as a i16 is: {}", 128 as i16);
// In boundary case 128 value in 8-bit two's complement representation is -128
println!(" 128 as a i8 is : {}", 128 as i8);
// repeating the example above
// 1000 as u8 -> 232
println!("1000 as a u8 is : {}", 1000 as u8);
// and the value of 232 in 8-bit two's complement representation is -24
println!(" 232 as a i8 is : {}", 232 as i8);
// Since Rust 1.45, the `as` keyword performs a *saturating cast*
// when casting from float to int. If the floating point value exceeds
// the upper bound or is less than the lower bound, the returned value
// will be equal to the bound crossed.
// 300.0 as u8 is 255
println!(" 300.0 as u8 is : {}", 300.0_f32 as u8);
// -100.0 as u8 is 0
println!("-100.0 as u8 is : {}", -100.0_f32 as u8);
// nan as u8 is 0
println!(" nan as u8 is : {}", f32::NAN as u8);
// This behavior incurs a small runtime cost and can be avoided
// with unsafe methods, however the results might overflow and
// return **unsound values**. Use these methods wisely:
unsafe {
// 300.0 as u8 is 44
println!(" 300.0 as u8 is : {}", 300.0_f32.to_int_unchecked::());
// -100.0 as u8 is 156
println!("-100.0 as u8 is : {}", (-100.0_f32).to_int_unchecked::());
// nan as u8 is 0
println!(" nan as u8 is : {}", f32::NAN.to_int_unchecked::());
}
}
// This function only gets compiled if the target OS is linux
#[cfg(target_os = "linux")]
fn are_you_on_linux() {
println!("You are running linux!");
}
// And this function only gets compiled if the target OS is *not* linux
#[cfg(not(target_os = "linux"))]
fn are_you_on_linux() {
println!("You are *not* running linux!");
}
fn main() {
are_you_on_linux();
println!("Are you sure?");
if cfg!(target_os = "linux") {
println!("Yes. It's definitely linux!");
} else {
println!("Yes. It's definitely *not* linux!");
}
}
struct Droppable {
name: &'static str,
}
// This trivial implementation of `drop` adds a print to console.
impl Drop for Droppable {
fn drop(&mut self) {
println!("> Dropping {}", self.name);
}
}
fn main() {
let _a = Droppable { name: "a" };
// block A
{
let _b = Droppable { name: "b" };
// block B
{
let _c = Droppable { name: "c" };
let _d = Droppable { name: "d" };
println!("Exiting block B");
}
println!("Just exited block B");
println!("Exiting block A");
}
println!("Just exited block A");
// Variable can be manually dropped using the `drop` function
drop(_a);
// TODO ^ Try commenting this line
println!("end of the main function");
// `_a` *won't* be `drop`ed again here, because it already has been
// (manually) `drop`ed
}
#include "Comms.h"
Subdevice::Subdevice(const uint8_t _address, Device& _device) :
address(_address),
next(NULL),
device(_device)
{
device.AddSubdevice(this);
}
MainSubdevice::MainSubdevice(const uint8_t _address, Device& _device) :
Subdevice(_address, _device)
{}
void MainSubdevice::command(const uint32_t cmd)
{
switch (cmd)
{
case MAINSUBDEVICE_CMD_PING: cmd_ping(); break;
case MAINSUBDEVICE_CMD_LIST_SUBDEVICES: cmd_list_subdevices(); break;
default:
device.send32(ERROR_BAD_COMMAND);
break;
}
}
void MainSubdevice::cmd_ping()
{
device.send32(ACK);
}
void MainSubdevice::cmd_list_subdevices()
{
int size = 9;
uint32_t* p = (uint32_t*) (device.txBuffer + 4);
*p++ = id();
Subdevice* subdevice = this;
while (subdevice = subdevice->next)
{
*p++ = subdevice->id();
size += 4;
}
device.finishPacket(size);
}
Device::Device(const uint8_t _address) :
address(_address),
subdevices(NULL),
mainSubdevice(MainSubdevice(0, *this))
{
Serial.begin(115200);
rxHead = 0;
rxTail = 0;
lastRX = millis();
}
void Device::pump()
{
readSerial();
int rec = rxTail - rxHead;
if (rec < 0) rec += RX_BUFFER_SIZE;
if (rec >= 2)
{
uint8_t a = rxBuffer[rxHead];
uint8_t b = rxBuffer[(rxHead + 1) & RX_BUFFER_MASK];
int exp = (b << 8) | a;
if (exp == rec)
{
if (exp < 9)
{
// malformed packet
Serial.println("malform"); // TODO
rxHead = (rxHead + exp) & RX_BUFFER_MASK;
}
else if (!checkChecksum())
{
// failed checksum
Serial.println("badchecsum"); // TODO
rxHead = (rxHead + exp) & RX_BUFFER_MASK;
}
else
{
uint16_t size = consume16();
uint8_t deviceAddress = consume8();
if (deviceAddress != address)
{
rxHead = (rxHead + size - 3) & RX_BUFFER_MASK;
}
else
{
uint8_t subdeviceAddress = consume8();
uint32_t command = consume32();
int endOfPacket = (rxHead + size - 8) & RX_BUFFER_MASK;
dispatch(subdeviceAddress, command);
rxHead = endOfPacket;
}
}
}
}
}
void Device::readSerial()
{
if (Serial.available())
{
uint8_t input = Serial.read();
rxBuffer[rxTail++] = input;
rxTail &= RX_BUFFER_MASK;
if (rxTail == rxHead)
{
// overflow
}
Serial.write(input);// TODO
lastRX = millis();
}
else if (rxTail != rxHead)
{
uint32_t timeSinceReceive = millis() - lastRX;
if (timeSinceReceive >= RX_TIMEOUT)
{
Serial.println("tieout"); // TODO
rxHead = rxTail;
}
}
}
void Device::dispatch(const uint8_t subdeviceAddress, const uint32_t cmd)
{
Subdevice* subdevice = subdevices;
while (subdevice != NULL)
{
if (subdevice->address == subdeviceAddress)
{
subdevice->command(cmd);
return;
}
subdevice = subdevice->next;
}
send32(ERROR_SUBDEVICE_NOT_FOUND);
}
uint8_t Device::consume8()
{
uint8_t a = rxBuffer[rxHead++];
rxHead &= RX_BUFFER_MASK;
return a;
}
uint16_t Device::consume16()
{
uint8_t a = rxBuffer[rxHead++];
rxHead &= RX_BUFFER_MASK;
uint8_t b = rxBuffer[rxHead++];
rxHead &= RX_BUFFER_MASK;
return (((uint16_t)b) << 8) | ((uint16_t) a);
}
uint32_t Device::consume32()
{
uint8_t a = rxBuffer[rxHead++];
rxHead &= RX_BUFFER_MASK;
uint8_t b = rxBuffer[rxHead++];
rxHead &= RX_BUFFER_MASK;
uint8_t c = rxBuffer[rxHead++];
rxHead &= RX_BUFFER_MASK;
uint8_t d = rxBuffer[rxHead++];
rxHead &= RX_BUFFER_MASK;
return (((uint32_t)d) << 24) | (((uint32_t)c) << 16) | (((uint32_t)b) << 8) | ((uint32_t)a);
}
void Device::send32(const uint32_t msg)
{
uint32_t* p = (uint32_t*) (txBuffer + 4);
*p = msg;
finishPacket(9);
}
static const uint8_t crc_table[] =
{
0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31,
0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65,
0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9,
0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd,
0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1,
0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2,
0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe,
0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a,
0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16,
0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42,
0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80,
0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4,
0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8,
0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c,
0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10,
0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34,
0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f,
0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b,
0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7,
0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83,
0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef,
0xfa, 0xfd, 0xf4, 0xf3
};
bool Device::checkChecksum()
{
uint8_t crc = 0;
int c = rxHead;
int ce = rxTail - 1;
while (c != ce)
{
crc = crc_table[crc ^ rxBuffer[c++]];
c &= RX_BUFFER_MASK;
}
return crc == rxBuffer[c];
}
void Device::finishPacket(const int len)
{
txBuffer[0] = len & 0xff;
txBuffer[1] = len >> 8;
txBuffer[2] = 0;
txBuffer[3] = 0;
uint8_t crc = 0;
uint8_t* p = txBuffer;
uint8_t* pe = txBuffer + len - 1;
while(p < pe)
{
crc = crc_table[crc ^ *p++];
}
*p = crc;
Serial.write(txBuffer, len);
}
void Device::AddSubdevice(Subdevice* subdevice)
{
if (subdevices == NULL)
{
subdevices = subdevice;
}
else
{
Subdevice* dev = subdevices;
while (dev->next) dev = dev->next;
dev->next = subdevice;
}
}
# ExLlama
A standalone Python/C++/CUDA implementation of Llama for use with 4-bit GPTQ weights, designed to be fast and
memory-efficient on modern GPUs.
Disclaimer: The project is coming along, but it's still a work in progress!
## Hardware requirements
I am developing on an RTX 4090 and an RTX 3090-Ti. 30-series and later NVIDIA GPUs should be well supported, but
anything Pascal or older with poor FP16 support isn't going to perform well.
[AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) or [GPTQ-for-LLaMa](https://github.com/qwopqwop200/GPTQ-for-LLaMa)
are better options at the moment for older GPUs. ROCm is also theoretically supported (via HIP) though I currently
have no AMD devices to test or optimize on.
## Dependencies
* Python 3.9 or newer
* `torch` tested on 2.0.1 and 2.1.0 (nightly) with cu118
* `safetensors` 0.3.2
* `sentencepiece`
* `ninja`
Additionally, only for the web UI:
* `flask`
* `waitress`
## Linux/WSL prerequisites
pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu118
## Windows prerequisites
To run on Windows (without WSL):
1. Install [MSVC 2022](https://visualstudio.microsoft.com/downloads/). You can choose to install the whole `Visual
Studio 2022` IDE, or alternatively just the `Build Tools for Visual Studio 2022` package (make sure `Desktop
development with C++` is ticked in the installer), it doesn't really matter which.
2. Install the appropriate version of [PyTorch](https://pytorch.org/get-started/locally/), choosing one of the CUDA
versions. I am developing on the nightly build, but the stable version (2.0.1) should also work.
3. Install CUDA Toolkit, ([11.7](https://developer.nvidia.com/cuda-11-7-0-download-archive) and
[11.8](https://developer.nvidia.com/cuda-11-8-0-download-archive) both seem to work, just make sure to match PyTorch's
Compute Platform version).
4. For best performance, enable Hardware Accelerated GPU Scheduling.
## How to
Clone repo, install dependencies, and run benchmark:
git clone https://github.com/turboderp/exllama
cd exllama
pip install -r requirements.txt
python test_benchmark_inference.py -d -p -ppl
The CUDA extension is loaded at runtime so there's no need to install it separately. It will be compiled on the first
run and cached to `~/.cache/torch_extensions/` which could take a little while. If nothing happens at first, give it
a minute to compile.
Chatbot example:
python example_chatbot.py -d -un "Jeff" -p prompt_chatbort.txt
## Python module
jllllll currently maintains an installable Python module [here](https://github.com/jllllll/exllama) which may be more
suitable for integrating ExLlama with other projects
## Web UI
I also made a simple web UI for it. Don't look at the JavaScript, it was mostly written by ChatGPT and it will haunt
your dreams. But it sort of works, and it's kinda fun, especially multibot mode:
![_screenshot.jpg](doc/_screenshot.jpg)
To run it:
pip install -r requirements-web.txt
python webui/app.py -d
Note that sessions are stored in `~/exllama_sessions/` by default. You can change that location with `-sd` if you want.
## Docker
For security benefits and easier deployment, it is also possible to run the web UI in an isolated docker container. Note: the docker image currently only supports NVIDIA GPUs.
### Requirements
- [Docker](https://docs.docker.com/engine/install/)
- [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html)
It is recommended to run docker in [rootless mode](https://docs.docker.com/engine/security/rootless/).
### Build
The easiest way to build the docker image is using docker compose. First, set the `MODEL_PATH` and `SESSIONS_PATH` variables in the `.env` file to the actual directories on the host. Then run:
```
docker compose build
```
It is also possible to manually build the image:
```
docker build -t exllama-web .
```
NOTE: by default, the service inside the docker container is run by a non-root user. Hence, the ownership of bind-mounted directories (`/data/model` and `/data/exllama_sessions` in the default `docker-compose.yml` file) is changed to this non-root user in the container entrypoint (`entrypoint.sh`). To disable this, set `RUN_UID=0` in the `.env` file if using `docker compose`, or the following command if you manually build the image:
```
docker build -t exllama-web --build-arg RUN_UID=0 .
```
### Run
Using docker compose:
```
docker compose up
```
The web UI can now be accessed on the host at http://localhost:5000.
The configuration can be viewed in `docker-compose.yml` and changed by creating a `docker-compose.override.yml` file.
Run manually:
```
docker run --gpus all -p 5000:5000 -v :/data/model/ -v :/data/exllama_sessions --rm -it exllama-web --host 0.0.0.0:5000
```
## Results so far
### New implementation
| Model | Size | grpsz | act | Seq. len. | VRAM | Prompt | Best | Worst | Ppl |
|------------|-------|-------|-----|----------------------|-----------|------------|---------|---------|------|
| Llama | 7B | 128 | no | 2,048 t | 5,194 MB | 13,918 t/s | 173 t/s | 140 t/s | 6.45 |
| Llama | 13B | 128 | no | 2,048 t | 9,127 MB | 7,507 t/s | 102 t/s | 86 t/s | 5.60 |
| Llama | 33B | 128 | no | 2,048 t | 20,795 MB | 2,959 t/s | 47 t/s | 40 t/s | 4.60 |
| Llama | 33B | 128 | yes | 2,048 t | 20,795 MB | 2,784 t/s | 45 t/s | 37 t/s | 4.55 |
| Llama | 33B | 32 | yes | 1,550 t 1 | 21,486 MB | 2,636 t/s | 41 t/s | 37 t/s | 4.52 |
| Koala | 13B | 128 | yes | 2,048 t | 9,127 MB | 5,529 t/s | 93 t/s | 79 t/s | 6.73 |
| WizardLM | 33B | - | yes | 2,048 t | 20,199 MB | 2,313 t/s | 47 t/s | 40 t/s | 5.75 |
| OpenLlama | 3B | 128 | yes | 2,048 t | 3,128 MB | 16,419 t/s | 226 t/s | 170 t/s | 7.81 |
1 Can not achieve full sequence length without OoM
All tests done on stock RTX 4090 / 12900K, running with a desktop environment, with a few other apps also using VRAM.
**"Prompt"** speed is inference over the sequence length listed minus 128 tokens. **"Worst"** is the average speed for
the last 128 tokens of the full context (worst case) and **"Best"** lists the speed for the first 128 tokens in an
empty sequence (best case.)
VRAM usage is as reported by PyTorch and does not include PyTorch's own overhead (CUDA kernels,
internal buffers etc.) This is somewhat unpredictable anyway. Best bet is to just optimize VRAM usage by the model,
probably aiming for 20 GB on a 24 GB GPU to ensure there is room for a desktop environment and all of Torch's
internals.
Perplexity is measured only to verify that the models are working. The dataset used is a particular, small sample from
WikiText, so scores are not comparable to other Llama benchmarks and only useful for comparing the different Llama
models to one another.
### Dual GPU results
The following benchmarks are from a 4090 + 3090-Ti with `-gs 17.2,24`:
| Model | Size | groupsize | act | Seq. len. | VRAM | Prompt | Best | Worst | Ppl |
|---------|------|-----------|-----|----------------|-----------|-----------|--------|---------|-------|
| Llama | 65B | 128 | yes | 2,048 t | 39,804 MB | 1,109 t/s | 20 t/s | 18 t/s | 4.20 |
| Llama | 65B | 32 | yes | 2,048 t | 43,424 MB | 1,037 t/s | 17 t/s | 16 t/s | 4.11 |
| Llama-2 | 70B | 128 | yes | 2,048 t | 40,680 MB | 914 t/s | 17 t/s | 14 t/s | 4.15 |
| Llama-2 | 70B | 32 | yes | 2,048 t | 36,815 MB | 874 t/s | 15 t/s | 12 t/s | 4.10 |
Note that perplexity scores may not be strictly apples-to-apples between Llama and Llama 2 due to their different
pretraining datasets.
## Todo
Moved the todo list [here](doc/TODO.md).
## Compatibility
[Here](doc/model_compatibility.md) is a list of models confirmed to be working right now.
import * as util from "./util.js";
import * as mainmenu from "./mainmenu.js";
import * as globals from "./globals.js";
import * as controls from "./controls.js";
import * as overlay from "./overlay.js";
export class NotepadSettings {
constructor(parent) {
this.element = util.newHFlex();
this.parent = parent;
this.settings = this.parent.notepadSettings;
//console.log(this.settings);
this.populate();
}
populate() {
this.element.innerHTML = "";
this.sss_genParams = new controls.CollapsibleSection(null, "Generation parameters");
this.sss_sampling = new controls.CollapsibleSection(null, "Sampling");
this.element.appendChild(this.sss_genParams.element);
this.element.appendChild(this.sss_sampling.element);
// Generation params
this.sss_i_maxTokens = new controls.SettingsSlider("sss-item-left", "Max tokens", "sss-item-mid", "sss-item-right sss-item-textbox-r", 0, 16, 2048, null, this.settings, "maxtokens", () => { this.updateView(true); });
this.sss_i_chunkTokens = new controls.SettingsSlider("sss-item-left", "Chunk tokens", "sss-item-mid", "sss-item-right sss-item-textbox-r", 0, 16, 2048, null, this.settings, "chunktokens", () => { this.updateView(true); });
this.sss_stopConditions = new controls.CollapsibleSection(null, "Stop conditions");
this.sss_genParams.inner.appendChild(this.sss_i_maxTokens.element);
this.sss_genParams.inner.appendChild(this.sss_i_chunkTokens.element);
this.element.appendChild(this.sss_stopConditions.element);
// Sampling
this.sss_i_temperature = new controls.SettingsSlider("sss-item-left", "Temperature", "sss-item-mid", "sss-item-right sss-item-textbox-r", 2, 0, 3, null, this.settings, "temperature", () => { this.updateView(true); });
this.sss_i_topK = new controls.SettingsSlider("sss-item-left", "Top K", "sss-item-mid", "sss-item-right sss-item-textbox-r", 0, 0, 1000, { "0": "off" }, this.settings, "top_k", () => { this.updateView(true); });
this.sss_i_topP = new controls.SettingsSlider("sss-item-left", "Top P", "sss-item-mid", "sss-item-right sss-item-textbox-r", 2, 0, 1, { "0.00": "off", "1.00": "off" }, this.settings, "top_p", () => { this.updateView(true); });
this.sss_i_minP = new controls.SettingsSlider("sss-item-left", "Min P", "sss-item-mid", "sss-item-right sss-item-textbox-r", 2, 0, 1, { "0.00": "off", "1.00": "off" }, this.settings, "min_p", () => { this.updateView(true); });
this.sss_i_tfs = new controls.SettingsSlider("sss-item-left", "TFS", "sss-item-mid", "sss-item-right sss-item-textbox-r", 2, 0, 1, { "0.00": "off", "1.00": "off" }, this.settings, "tfs", () => { this.updateView(true); });
this.sss_i_typical = new controls.SettingsSlider("sss-item-left", "Typical", "sss-item-mid", "sss-item-right sss-item-textbox-r", 2, 0, 1, { "0.00": "off", "1.00": "off" }, this.settings, "typical", () => { this.updateView(true); });
this.sss_i_repPenalty = new controls.SettingsSlider("sss-item-left", "Rep. penalty", "sss-item-mid", "sss-item-right sss-item-textbox-r", 2, 1, 3, { "1.00": "off" }, this.settings, "repp", () => { this.updateView(true); });
this.sss_i_repRange = new controls.SettingsSlider("sss-item-left", "Rep. range", "sss-item-mid", "sss-item-right sss-item-textbox-r", 0, 0, 4096, { "0": "off" }, this.settings, "repr", () => { this.updateView(true); });
this.sss_i_mirostat = new controls.CheckboxLabel("sss-item-right clickable", "Mirostat", this.settings, "mirostat", () => { this.updateView(true); });
this.sss_i_mirostat_tau = new controls.SettingsSlider("sss-item-left", "Mirostat tau", "sss-item-mid", "sss-item-right sss-item-textbox-r", 2, 0.01, 10, null, this.settings, "mirostat_tau", () => { this.updateView(true); });
this.sss_i_mirostat_eta = new controls.SettingsSlider("sss-item-left", "Mirostat eta", "sss-item-mid", "sss-item-right sss-item-textbox-r", 2, 0.01, 5, null, this.settings, "mirostat_eta", () => { this.updateView(true); });
this.sss_sampling.inner.appendChild(this.sss_i_temperature.element);
this.sss_sampling.inner.appendChild(this.sss_i_topK.element);
this.sss_sampling.inner.appendChild(this.sss_i_topP.element);
this.sss_sampling.inner.appendChild(this.sss_i_minP.element);
this.sss_sampling.inner.appendChild(this.sss_i_tfs.element);
this.sss_sampling.inner.appendChild(this.sss_i_typical.element);
this.sss_sampling.inner.appendChild(this.sss_i_repPenalty.element);
this.sss_sampling.inner.appendChild(this.sss_i_repRange.element);
this.sss_sampling.inner.appendChild(this.sss_i_mirostat.element);
this.sss_sampling.inner.appendChild(this.sss_i_mirostat_tau.element);
this.sss_sampling.inner.appendChild(this.sss_i_mirostat_eta.element);
// Stop conditions
this.populate_stop_conditions();
this.updateView();
}
populate_stop_conditions() {
this.sss_stopConditions.inner.innerHTML = "";
this.sss_i_stopconditions = [];
for (let i = 0; i < this.settings.stop_conditions.length; i++) {
this.sss_i_stopconditions[i] = new controls.CheckboxTextboxButton(
"stop_condition_" + i,
"sss-item-left",
"Incl.",
"sss-item-mid sss-item-textbox",
"",
this.settings,
"stop_conditions",
i,
"text",
"inclusive",
(v) => { return v != ""; },
() => { this.updateView(true); },
"✕ Remove",
() => {
this.settings.stop_conditions.splice(i, 1);
this.populate_stop_conditions();
this.updateView(true);
}
);
}
for (let i = 0; i < this.settings.stop_conditions.length; i++)
this.sss_stopConditions.inner.appendChild(this.sss_i_stopconditions[i].element);
if (this.settings.stop_conditions.length < 10) {
this.sss_i_addStopCondition = new controls.LinkButton("+ Add...", null, () => {
this.settings.stop_conditions.push({text: "", inclusive: false});
this.populate_stop_conditions();
this.updateView(true);
}, "sss-item-link");
this.sss_stopConditions.inner.appendChild(this.sss_i_addStopCondition.element);
}
}
updateView(send = false) {
// Settings visibility
let mirostat = this.settings.mirostat;
this.sss_i_mirostat_tau.setVisible(mirostat);
this.sss_i_mirostat_eta.setVisible(mirostat);
// Send
if (send) this.send();
//console.log(this.settings);
}
send(post = null) {
//console.log(this.settings);
let packet = {};
packet.settings = this.settings;
if (!this.parent.notepadID || this.parent.notepadID == "new") {
fetch("/api/new_notepad", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(packet) })
.then(response => response.json())
.then(response => {
this.parent.parent.lastNotepadUUID = response.notepad.notepad_uuid;
this.parent.parent.onEnter();
if (post) post(response);
});
} else {
fetch("/api/update_notepad_settings", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(packet) })
.then(response => response.json())
.then(response => {
if (post) post(response);
});
}
}
}
input[type=range] {
-webkit-appearance: none;
margin: 4px 0;
width: 100%;
background: transparent;
}
input[type=range]:focus {
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 6.4px;
cursor: pointer;
box-shadow: 1px 1px 1px #00000020, 0px 0px 1px #0d0d0d40;
background: var(--slider-track-color);
border-radius: 1.0px;
border: 0.2px solid #01010120;
}
input[type=range]::-webkit-slider-thumb {
box-shadow: 1px 1px 1px #00000080, 0px 0px 1px #0d0d0d40;
border: 1px solid #00000080;
height: 16px;
width: 16px;
border-radius: 3px;
background: var(--slider-thumb-color);
cursor: pointer;
-webkit-appearance: none;
margin-top: -5px;
}
input[type=range]:hover::-webkit-slider-runnable-track {
/* background: var(--slider-hover-color);*/
}
input[type=range]::-moz-range-track {
width: 100%;
height: 4.4px;
cursor: pointer;
box-shadow: 1px 1px 1px #00000080, 0px 0px 1px #0d0d0d40;
background: var(--slider-track-color);
border-radius: 1.3px;
border: 0.2px solid var(--slider-track-color);;
}
input[type=range]::-moz-range-thumb {
box-shadow: 1px 1px 1px #00000080, 0px 0px 1px #0d0d0d40;
border: 1px solid #00000080;
height: 13px;
width: 13px;
border-radius: 3px;
background: var(--slider-thumb-color);
cursor: pointer;
}
input[type=range]:hover::-moz-range-track {
/* background: var(--slider-hover-color);*/
}
import * as util from "./util.js";
class PageOverlay {
constructor() {
this.keyboardDisabled = false;
document.addEventListener("keydown", (e) => {
if (this.keyboardDisabled) e.preventDefault();
});
this.overlayElement = util.newDiv(null, "page-overlay");
document.body.appendChild(this.overlayElement);
this.items = new Map();
}
add(mode, control) {
this.items.set(mode, control);
this.overlayElement.appendChild(control.element);
return control;
}
setMode(mode = null) {
if (!mode) {
this.keyboardDisabled = false;
this.overlayElement.style.display = "none";
this.items.forEach((v, k) => { v.setVisible(false); });
} else {
this.keyboardDisabled = true;
this.overlayElement.style.display = "flex";
this.items.forEach((v, k) => { v.setVisible(mode === k); });
}
}
}
class Overlay {
constructor() {
this.element = util.newDiv(null, "overlay");
}
setVisible(visible) {
this.element.style.display = visible ? "flex" : "none";
}
}
class BusyOverlay extends Overlay {
constructor() {
super();
this.element.innerHTML = "" +
"";
}
}
class LoadingOverlay extends Overlay {
constructor() {
super();
this.element.innerHTML = "";
this.box = util.newDiv(null, "progressbar-box");
this.element.appendChild(this.box);
this.bar = util.newDiv(null, "progressbar-bar");
this.box.appendChild(this.bar);
}
setProgress(a, b) {
let percentage = 100 * (a / b);
this.bar.style.width = percentage + '%';
}
}
export var pageOverlay = new PageOverlay();
export var busyOverlay = pageOverlay.add("busy", new BusyOverlay());
export var loadingOverlay = pageOverlay.add("loading", new LoadingOverlay());
@app.route("/api/load_model", methods=['POST'])
def api_load_model():
global api_lock, verbose
if verbose: print("/api/load_model")
with api_lock:
data = request.get_json()
if verbose: print("<-", data)
if verbose: print("-> ...")
result = Response(stream_with_context(load_model(data)), mimetype = 'application/json')
if verbose: print("->", result)
return result
@app.route("/api/unload_model")
def api_unload_model():
global api_lock, verbose
if verbose: print("/api/unload_model")
with api_lock:
result = unload_model()
if verbose: print("->", result)
return json.dumps(result) + "\n"
@app.route("/api/list_sessions")
def api_list_sessions():
global api_lock, verbose
if verbose: print("/api/list_sessions")
with api_lock:
s, c = list_sessions()
result = { "result": "ok", "sessions": s, "current_session": c }
if verbose: print("-> (...)")
return json.dumps(result) + "\n"
@app.route("/api/get_default_settings")
def api_get_default_settings():
global api_lock, verbose
if verbose: print("/api/get_default_settings")
with api_lock:
result = { "result": "ok",
"session_settings": get_default_session_settings(),
"notepad_settings": get_default_notepad_settings(),
"prompt_formats": list_prompt_formats() }
return json.dumps(result) + "\n"
@app.route("/api/set_session", methods=['POST'])
def api_set_session():
global api_lock, verbose
if verbose: print("/api/set_session")
with api_lock:
data = request.get_json()
if verbose: print("<-", data)
session = set_session(data)
if session is not None:
result = { "result": "ok",
"session": session,
"prompt_formats": list_prompt_formats() }
if verbose: print("-> (...)")
else:
result = { "result": "fail" }
if verbose: print("->", result)
return json.dumps(result) + "\n"
@app.route("/api/new_session", methods=['POST'])
def api_new_session():
global api_lock, verbose
if verbose: print("/api/new_session")
with api_lock:
data = request.get_json()
if verbose: print("<-", data)
session = new_session()
if "settings" in data: get_session().update_settings(data["settings"])
if "user_input_text" in data: get_session().user_input(data)
if "new_name" in data: get_session().rename(data)
result = { "result": "ok", "session": session }
if verbose: print("-> (...)")
return json.dumps(result) + "\n"
@app.route("/api/rename_session", methods=['POST'])
def api_rename_session():
global api_lock, verbose
if verbose: print("/api/rename_session")
with api_lock:
data = request.get_json()
if verbose: print("<-", data)
s = get_session()
s.rename(data)
result = { "result": "ok" }
if verbose: print("->", result)
return json.dumps(result) + "\n"
def is_rocm_installed():
# Implement a check for ROCm (e.g., looking for specific files or running a command)
# Return True if ROCm is found, False otherwise
pass
def is_cuda_installed():
# Implement a check for CUDA
# Return True if CUDA is found, False otherwise
pass
def install_packages():
if is_rocm_installed():
subprocess.run([sys.executable, '-m', 'pip', 'install', 'some_rocm_package'])
elif is_cuda_installed():
subprocess.run([sys.executable, '-m', 'pip', 'install', 'some_cuda_package'])
else:
print("Neither ROCm nor CUDA detected.")
if __name__ == "__main__":
install_packages()
#ifndef _qdq_4_cuh
#define _qdq_4_cuh
#include "qdq_util.cuh"
#include "../../config.h"
#if QMODE_4BIT == 1
// Permutation:
//
// 77775555 33331111 66664444 22220000
__forceinline__ __device__ void shuffle_4bit_8
(
uint32_t* q,
int stride
)
{
uint32_t qa = q[0];
uint32_t qb = 0;
#pragma unroll
for (int i = 0; i < 4; i++)
{
uint32_t qa0 = qa & 0x0f;
uint32_t qa1 = (qa & 0xf0) >> 4;
qa >>= 8;
qb |= (qa1 << (i * 4 + 16));
qb |= (qa0 << (i * 4));
}
q[0] = qb;
}
__forceinline__ __device__ void dequant_4bit_8
(
const uint32_t q_0,
half2 (&dq)[4],
int stride
)
{
const uint32_t c0 = 0x64006400;
const half y16_ = __float2half_rn(1.0f / 16.0f);
const half2 y16 = __halves2half2(y16_, y16_);
const half z1_ = __float2half_rn(-1024.0f - 8.0f);
const half z16_ = __float2half_rn(-1024.0f / 16.0f - 8.0f);
const half2 z1 = __halves2half2(z1_, z1_);
const half2 z16 = __halves2half2(z16_, z16_);
uint32_t qa = q_0;
half2_uint32 q0((qa & 0x000f000f) | c0); // half2(q[ 0], q[ 1]) + 1024
half2_uint32 q1((qa & 0x00f000f0) | c0); // half2(q[ 2], q[ 3]) * 16 + 1024
qa >>= 8;
half2_uint32 q2((qa & 0x000f000f) | c0); // half2(q[ 4], q[ 5]) + 1024
half2_uint32 q3((qa & 0x00f000f0) | c0); // half2(q[ 6], q[ 7]) * 16 + 1024
dq[0] = __hadd2(q0.as_half2, z1);
dq[1] = __hfma2(q1.as_half2, y16, z16);
dq[2] = __hadd2(q2.as_half2, z1);
dq[3] = __hfma2(q3.as_half2, y16, z16);
}
__forceinline__ __device__ void dequant_4bit_8_prep_zero_scale
(
const uint32_t zero,
const half scale,
half2 (&z1z16)[2],
half2 (&y1y16)[2]
)
{
half_uint16 z1(0xe400 | zero); // half(-1024.0f - zero);
half z16 = __hsub(__int2half_rn(-64), __int2half_rn(zero));
half2 scale2 = __half2half2(scale);
z1z16[0] = __hmul2(scale2, __half2half2(z1.as_half));
z1z16[1] = __hmul2(scale2, __half2half2(z16));
const half y1 = __float2half_rn(1.0f);
const half y16 = __float2half_rn(1.0f / 16.0f);
y1y16[0] = __hmul2(scale2, __half2half2(y1));
y1y16[1] = __hmul2(scale2, __half2half2(y16));
}
__forceinline__ __device__ void dequant_4bit_8_prep_zero
(
const uint32_t zero,
half2(&z1z16)[2],
half2(&y1y16)[2]
)
{
half_uint16 z1(0xe400 | zero); // half(-1024.0f - zero);
half z16 = __hsub(__int2half_rn(-64), __int2half_rn(zero));
z1z16[0] = __half2half2(z1.as_half);
z1z16[1] = __half2half2(z16);
const half y1 = __float2half_rn(1.0f);
const half y16 = __float2half_rn(1.0f / 16.0f);
y1y16[0] = __half2half2(y1);
y1y16[1] = __half2half2(y16);
}
__forceinline__ __device__ void dequant_4bit_8_gptq
(
const uint32_t q_0,
half2 (&dq)[4],
half2 (&z1z16)[2],
half2 (&y1y16)[2],
int stride,
bool scaled
)
{
const uint32_t c0 = 0x64006400;
uint32_t qa = q_0;
half2_uint32 q0((qa & 0x000f000f) | c0); // half2( q[0] + 1024, q[1] + 1024 )
half2_uint32 q1((qa & 0x00f000f0) | c0); // half2( q[2] * 16 + 1024, q[3] * 16 + 1024 )
qa >>= 8;
half2_uint32 q2((qa & 0x000f000f) | c0); // half2( q[4] + 1024, q[5] + 1024 )
half2_uint32 q3((qa & 0x00f000f0) | c0); // half2( q[6] * 16 + 1024, q[7] * 16 + 1024 )
if (scaled)
{
dq[0] = __hfma2(q0.as_half2, y1y16[0], z1z16[0]); // half2( q[0] * s - z * s, q[1] * s - z * s)
dq[1] = __hfma2(q1.as_half2, y1y16[1], z1z16[1]); // half2( q[2] * s - z * s, q[3] * s - z * s)
dq[2] = __hfma2(q2.as_half2, y1y16[0], z1z16[0]);
dq[3] = __hfma2(q3.as_half2, y1y16[1], z1z16[1]);
}
else
{
dq[0] = __hadd2(q0.as_half2, z1z16[0]); // half2( q[0] - z, q[1] - z )
dq[1] = __hfma2(q1.as_half2, y1y16[1], z1z16[1]); // half2( q[2] - z, q[3] - z )
dq[2] = __hadd2(q2.as_half2, z1z16[0]); // half2( q[4] - z, q[5] - z )
dq[3] = __hfma2(q3.as_half2, y1y16[1], z1z16[1]); // half2( q[6] - z, q[7] - z )
}
}
#else
__forceinline__ __device__ void shuffle_4bit_8
(
uint32_t* q,
int stride
)
{
}
__forceinline__ __device__ void dequant_4bit_8
(
const uint32_t q_0,
half2 (&dq)[4],
int stride
)
{
half dqh[8];
for (int i = 0; i < 8; i++) dqh[i] = dq_ns(exb(q_0, i * 4, 0x0f), 8);
for (int i = 0; i < 4; i++) dq[i] = __halves2half2(dqh[i * 2], dqh[i * 2 + 1]);
}
__forceinline__ __device__ void dequant_4bit_8_prep_zero_scale
(
const uint32_t zero,
const half scale,
half2 (&z1)[2],
half2 (&y1)[2]
)
{
half z = __int2half_rn(-((int)zero));
z = __hmul(z, scale);
z1[0] = __half2half2(z);
y1[0] = __half2half2(scale);
}
__forceinline__ __device__ void dequant_4bit_8_prep_zero
(
const uint32_t zero,
half2(&z1)[2],
half2(&y1)[2]
)
{
half z = __int2half_rn(-((int)zero));
z1[0] = __half2half2(z);
}
__forceinline__ __device__ void dequant_4bit_8_gptq
(
const uint32_t q_0,
half2 (&dq)[4],
half2 (&z1)[2],
half2 (&y1)[2],
int stride,
bool scaled
)
{
half2 dqh2[8];
uint32_t qa = q_0;
for (int i = 0; i < 4; i++)
{
half d0 = __int2half_rn(qa & 0x0f); qa >>= 4;
half d1 = __int2half_rn(qa & 0x0f); qa >>= 4;
dqh2[i] = __halves2half2(d0, d1);
}
if (scaled)
{
dq[0] = __hfma2(dqh2[0], y1[0], z1[0]);
dq[1] = __hfma2(dqh2[1], y1[0], z1[0]);
dq[2] = __hfma2(dqh2[2], y1[0], z1[0]);
dq[3] = __hfma2(dqh2[3], y1[0], z1[0]);
}
else
{
dq[0] = __hadd2(dqh2[0], z1[0]);
dq[1] = __hadd2(dqh2[1], z1[0]);
dq[2] = __hadd2(dqh2[2], z1[0]);
dq[3] = __hadd2(dqh2[3], z1[0]);
}
}
#endif
#endif
import gc
import torch
from torch import nn
import torch.nn.functional as F
import math
from exllamav2.ext import exllamav2_ext as ext_c, none_tensor
from exllamav2.util import list_live_tensors
class AdaptiveQuantizer:
norm: float = 3.5
max_p: float = 1.0
min_p: float = 0.75
p_grid: int = 48
bits: int
scale_bits: int
scale_range: float = 1.0
scale: torch.tensor
qscale: torch.tensor
qscale_max: float
maxq: float
scale_maxq: float
qzero: float
def __init__(self,
bits: int = 4,
scale_bits: int = 4):
self.bits = bits
self.scale_bits = scale_bits
self.maxq = 2 ** bits - 1
self.qzero = (self.maxq + 1) / 2
self.scale_maxq = 2 ** scale_bits - 1
self.scale_maxq = (2 ** self.scale_bits) - 1
def find_params(self, x):
xmax, _ = torch.max(torch.abs(x), dim = 0)
xmax += 1e-12
base_scale = xmax / (self.maxq / 2)
qscale_max_t = torch.max(base_scale) * self.scale_range
scale_tp = base_scale / qscale_max_t
scale_tp = torch.sqrt(scale_tp)
scale_tp *= (self.scale_maxq + 1)
qscale_t = torch.clamp(torch.round(scale_tp), 1, self.scale_maxq + 1)
qscale_tw = qscale_t / (self.scale_maxq + 1)
qscale_tw = qscale_tw ** 2
qscale_tw *= qscale_max_t
q = torch.zeros((self.p_grid + 1, 128), dtype = torch.float, device = x.device)
ext_c.quantize_err(x, q, qscale_tw, self.qzero, self.maxq, self.norm, self.min_p, self.max_p, self.p_grid)
q = torch.sum(q, dim = 1)
best_pi = torch.argmin(q)
best_pif = best_pi / self.p_grid
best_p = self.max_p * best_pif + self.min_p * (1 - best_pif)
# best_p = 1.0
self.qscale = qscale_t.to(torch.short)
self.scale = qscale_tw * best_p
self.qscale_max = qscale_max_t * best_p
class AdaptiveGPTQ:
percdamp: float = 0.07
layer: nn.Linear
device: torch.device
group_size: int
bits: list
bits_groups: list
scale_bits: int
hot_bits: int
columns: int
rows: int
hessian: torch.tensor
total_groups: int
perm: torch.tensor = None
invperm: torch.tensor = None
g_idx: torch.tensor = None
scale: torch.tensor = None
qscale: torch.tensor = None
qscale_max: torch.tensor = None
qweight: torch.tensor = None
qgroups: torch.tensor = None
quant: torch.tensor = None
weights: torch.tensor = None
hessian: torch.tensor = None
hessian_inv: torch.tensor = None
num_samples: int = 0
num_batches: int = 0
def __init__(self,
layer: nn.Linear):
self.layer = layer
self.device = layer.weight.device
self.rows = self.layer.weight.data.shape[1]
self.columns = self.layer.weight.data.shape[0]
self.weights = self.layer.weight.data.T.clone().float().contiguous()
self.hessian = None
self.num_samples = 0
self.num_batches = 0
def drop_buffers(self):
self.perm = None
self.invperm = None
self.g_idx = None
self.scale = None
self.qscale = None
self.qscale_max = None
self.qweight = None
self.qgroups = None
self.quant = None
self.weights = None
self.hessian = None
self.hessian_inv = None
gc.collect()
torch.cuda.empty_cache()
def configure(self,
group_size: dict,
bits = None,
bits_prop = None,
scale_bits: int = 4
):
self.group_size = group_size
self.scale_bits = scale_bits
self.bits = bits
assert isinstance(bits, list)
assert isinstance(bits_prop, list)
assert sum(bits_prop) == 1
groups = 0
remaining_rows = self.rows
self.bits_groups = []
for b, p in zip(self.bits, bits_prop):
assert p > 0
gsz = self.group_size[b]
g = math.ceil(min(self.rows * p, remaining_rows) / gsz)
groups += g
remaining_rows -= g * gsz
self.bits_groups.append(g)
assert remaining_rows <= 0
self.total_groups = groups
# if isinstance(bits, list):
#
# self.bits = bits
# g128 = (self.rows + 128 - 1) // 128
# self.bits_groups = [max(round(g128 * p), 1) * 128 // self.group_size for p in bits_prop]
# e = sum(self.bits_groups) - self.total_groups
# self.bits_groups[-1] -= e
#
# else:
#
# self.bits = [bits]
# self.bits_groups = [self.total_groups]
# def num_bits(self, subtract_columns = 0):
#
# gi = self.g_idx.numel() * 32
# qs = self.qscale.numel() * self.scale_bits
# qss = self.qscale_max.numel() * 16
#
# w = 0
# tr = self.rows
# for g, b in zip(self.bits_groups, self.bits):
#
# c = self.columns - subtract_columns
# r = self.group_size * g
# if r > tr: r = tr
# tr -= r
# w += r * c * b
#
# return w + gi + qs + qss
def add_batch(self, inputs):
with torch.inference_mode():
if self.hessian is None:
self.hessian = torch.zeros((self.rows, self.rows), device=self.device, dtype=torch.float)
self.num_batches += 1
num_samples = len(inputs)
inputs = torch.cat(inputs, dim = 0)
inputs = inputs.view((-1, inputs.shape[-1])).float().T.to("cuda:0")
inputs *= math.sqrt(2 / num_samples)
self.hessian += inputs.matmul(inputs.T)
def prepare(self):
with torch.inference_mode():
self.hessian /= self.num_batches
diagonal = torch.diag(self.hessian)
# Zero weights that have no impact. Disabling this since it feels a little drastic based on just the calibration
# data. It likely never triggers, anyway.
# dead = diagonal == 0.0
# self.hessian[dead, dead] = 1
# self.weights[dead, :] = 0
# Activation order
self.perm = torch.argsort(diagonal, descending = True)
self.weights = self.weights[self.perm, :]
hessian = self.hessian[self.perm][:, self.perm]
self.hessian = None
# In case numerical errors have caused some asymmetry in H, assume it's close to symmetrical and force it.
# (Doesn't seem to be needed)
# torch.cuda.empty_cache()
# hessian = (hessian + hessian.T) * 0.5
# torch.cuda.empty_cache()
# Damping
diagonal = torch.diag(hessian)
damp = torch.clamp(self.percdamp * torch.mean(diagonal), min = 1e-5)
# Inverse of H
attempts = 0
while True:
try:
d = torch.arange(self.rows, device = self.device)
hessian[d, d] += damp
# Dump condition number and smallest eigenvalue (should be positive)
# fro_norm_hessian = torch.norm(hessian, p = 'fro')
# fro_norm_inv = torch.norm(torch.linalg.inv(hessian), p = 'fro')
# cond_number = fro_norm_hessian * fro_norm_inv
# print(cond_number)
# eigenvalues = torch.linalg.eigvalsh(hessian)
# is_pd = torch.all(eigenvalues > 0)
# print(is_pd)
# print(torch.min(eigenvalues))
hessian_inv = torch.linalg.cholesky(hessian)
hessian_inv = torch.cholesky_inverse(hessian_inv)
# The Cholesky inverse will sometimes fail to compute due to accumulated rounding errors when H
# is very large (e.g. 70B MLP down proj) and a lot of calibration data is used (e.g. 100 rows of
# 4096 tokens). This won't always throw an exception and sometimes just results in a NaN tensor.
if torch.any(torch.isnan(hessian_inv)): raise RuntimeError
# Test inversion
# test = hessian_inv @ hessian
# test.sub_(torch.eye(test.size(0), device = test.device, dtype = test.dtype))
# test **= 2
# test = test.mean()
# print(test)
hessian_inv = torch.linalg.cholesky(hessian_inv, upper = True)
hessian_inv = hessian_inv.contiguous()
break
except RuntimeError:
# If inverting failed, assume there were non-positive eigenvalues, so apply more damping to shift
# the eigenvalues in a positive direction.
print(" !! Warning: Applied additional damping")
attempts += 1
if attempts == 10:
raise ValueError("Hessian is not invertible")
self.hessian_inv = hessian_inv
self.hessian = None
def reuse_h(self, other):
with torch.inference_mode():
self.hessian_inv = other.hessian_inv
self.hessian = None
self.perm = other.perm
self.weights = self.weights[self.perm, :]
def quantize(self, keep_qweight = False, apply = False, drop = False):
with torch.inference_mode():
if apply:
weights = self.weights
self.layer.weight.data = torch.zeros((1, 1), dtype = torch.float32, device = weights.device)
else:
weights = self.weights.clone()
self.quant = torch.zeros_like(self.weights)
if keep_qweight:
self.qweight = torch.zeros_like(weights, dtype = torch.short)
# Quantize groups
scale = []
qscale = []
qscale_max = []
qgroups = []
error = weights.clone()
group_idx = 0
group_idx_list = []
b = 0
for bits_idx, bits in enumerate(self.bits):
quantizer = AdaptiveQuantizer(bits = bits, scale_bits = self.scale_bits)
for group in range(self.bits_groups[bits_idx]):
a = b
b = min(a + self.group_size[bits], self.rows)
qgroups.append(bits)
qgroups.append(0)
quantizer.find_params(weights[a : b, :])
scale.append(quantizer.scale)
qscale.append(quantizer.qscale)
qscale_max.append(quantizer.qscale_max)
ext_c.quantize_range(self.quant,
quantizer.scale,
self.qweight if keep_qweight else none_tensor,
quantizer.qzero,
quantizer.maxq,
self.hessian_inv,
weights,
error,
a,
b)
group_idx_list += [group_idx] * (b - a)
group_idx += 1
# Create g_idx to store inverse activation order
self.g_idx = torch.tensor(group_idx_list, dtype = torch.int32, device = self.device)
self.invperm = torch.argsort(self.perm)
self.g_idx = self.g_idx[self.invperm]
# Store scales
self.scale = torch.stack(scale, dim = 0)
self.qscale = torch.stack(qscale, dim = 0)
self.qscale_max = torch.tensor(qscale_max, dtype = torch.float16, device = self.device)
self.qgroups = torch.tensor(qgroups, dtype = torch.short, device = self.device)
# Apply
if apply:
if drop:
weights = None
error = None
scale = None
qscale = None
qscale_max = None
qgroups = None
group_idx_list = None
gc.collect()
torch.cuda.empty_cache()
self.apply_quant()
def quant_error(self):
with torch.inference_mode():
q = self.quant[self.invperm, :]
diff = torch.abs(q - self.layer.weight.data.T)
mat_error_1 = (diff > 0.01).sum().item() / diff.numel()
mat_error_5 = (diff > 0.05).sum().item() / diff.numel()
mat_error_10 = (diff > 0.10).sum().item() / diff.numel()
return mat_error_1, mat_error_5, mat_error_10
def apply_quant(self):
qc = self.quant.cpu()
invperm = self.invperm.cpu()
q = qc[invperm, :].T
q = q.reshape(self.quant.T.shape)
q = q.to(self.quant.device)
self.layer.weight.data = q
def apply_temp(self):
q = self.quant[self.invperm, :].T
temp_layer = nn.Linear(self.layer.in_features, self.layer.out_features, False, device = "meta", dtype = torch.float16)
temp_layer.weight = nn.Parameter(q.reshape(self.layer.weight.shape).type_as(self.layer.weight.data))
return temp_layer
def pack(self, key, qparams):
assert qparams.scale_bits in [4]
# assert self.columns % 32 == 0
output = {}
output[key + ".q_invperm"] = self.invperm.to(torch.int)
output[key + ".q_scale_max"] = self.qscale_max
output[key + ".q_groups"] = self.qgroups
columns = self.columns
rem_rows = self.rows
padding = -columns % 32
if padding != 0:
print(f" !! Note: Padding quantized tensor {key}")
qst = F.pad(self.qscale, (0, padding)).contiguous()
qwt = F.pad(self.qweight, (0, padding)).contiguous()
else:
qst = self.qscale
qwt = self.qweight
qst_packed = torch.zeros((qst.shape[0], qst.shape[1] * qparams.scale_bits // 32), dtype = torch.int32, device = self.device)
if qparams.scale_bits == 4: ext_c.pack_rows_4(qst, qst_packed)
# if qparams.scale_bits == 6: ext_c.pack_rows_6(qst, qst_packed) # TODO:
output[key + ".q_scale"] = qst_packed
qwt_packed = []
i = 0
row = 0
out_row = 0
while i < self.qscale.shape[0]:
bits = self.qgroups[i * 2].item()
self.qgroups[i * 2 + 1] = out_row
i += 1
rows = min(self.group_size[bits], rem_rows)
wpqr = 32 / bits
qrows = rows / wpqr
assert i == self.qgroups.shape[-1] or qrows == int(qrows)
qrows = math.ceil(qrows)
g_qwt = qwt[row:row+rows, :].contiguous()
g_qwt_packed = torch.zeros((qrows, columns + padding), dtype = torch.int32, device = self.device)
if padding > 0: g_qwt[:, -padding:] = 2 ** (bits - 1)
ext_c.pack_columns(g_qwt, g_qwt_packed, bits)
qwt_packed.append(g_qwt_packed)
# print(row, rows, bits)
row += rows
out_row += qrows
rem_rows -= rows
qwt_packed = torch.cat(qwt_packed, dim = 0)
output[key + ".q_weight"] = qwt_packed
return output
This page shows examples of messages formatted using JSON (JavaScript Object Notation).
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
The same text expressed as XML:
example glossary
S
Standard Generalized Markup Language
SGML
ISO 8879:1986
A meta-markup language, used to create markup
languages such as DocBook.
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
The same text expressed as XML:
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}
The same text expressed as XML:
on
main_window
500
500
250
250
center
text1
250
100
center
sun1.opacity = (sun1.opacity / 100) * 90;
{"web-app": {
"servlet": [
{
"servlet-name": "cofaxCDS",
"servlet-class": "org.cofax.cds.CDSServlet",
"init-param": {
"configGlossary:installationAt": "Philadelphia, PA",
"configGlossary:adminEmail": "ksm@pobox.com",
"configGlossary:poweredBy": "Cofax",
"configGlossary:poweredByIcon": "/images/cofax.gif",
"configGlossary:staticPath": "/content/static",
"templateProcessorClass": "org.cofax.WysiwygTemplate",
"templateLoaderClass": "org.cofax.FilesTemplateLoader",
"templatePath": "templates",
"templateOverridePath": "",
"defaultListTemplate": "listTemplate.htm",
"defaultFileTemplate": "articleTemplate.htm",
"useJSP": false,
"jspListTemplate": "listTemplate.jsp",
"jspFileTemplate": "articleTemplate.jsp",
"cachePackageTagsTrack": 200,
"cachePackageTagsStore": 200,
"cachePackageTagsRefresh": 60,
"cacheTemplatesTrack": 100,
"cacheTemplatesStore": 50,
"cacheTemplatesRefresh": 15,
"cachePagesTrack": 200,
"cachePagesStore": 100,
"cachePagesRefresh": 10,
"cachePagesDirtyRead": 10,
"searchEngineListTemplate": "forSearchEnginesList.htm",
"searchEngineFileTemplate": "forSearchEngines.htm",
"searchEngineRobotsDb": "WEB-INF/robots.db",
"useDataStore": true,
"dataStoreClass": "org.cofax.SqlDataStore",
"redirectionClass": "org.cofax.SqlRedirection",
"dataStoreName": "cofax",
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
"dataStoreUser": "sa",
"dataStorePassword": "dataStoreTestQuery",
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
"dataStoreInitConns": 10,
"dataStoreMaxConns": 100,
"dataStoreConnUsageLimit": 100,
"dataStoreLogLevel": "debug",
"maxUrlLength": 500}},
{
"servlet-name": "cofaxEmail",
"servlet-class": "org.cofax.cds.EmailServlet",
"init-param": {
"mailHost": "mail1",
"mailHostOverride": "mail2"}},
{
"servlet-name": "cofaxAdmin",
"servlet-class": "org.cofax.cds.AdminServlet"},
{
"servlet-name": "fileServlet",
"servlet-class": "org.cofax.cds.FileServlet"},
{
"servlet-name": "cofaxTools",
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
"init-param": {
"templatePath": "toolstemplates/",
"log": 1,
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
"logMaxSize": "",
"dataLog": 1,
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
"dataLogMaxSize": "",
"removePageCache": "/content/admin/remove?cache=pages&id=",
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
"lookInContext": 1,
"adminGroupID": 4,
"betaServer": true}}],
"servlet-mapping": {
"cofaxCDS": "/",
"cofaxEmail": "/cofaxutil/aemail/*",
"cofaxAdmin": "/admin/*",
"fileServlet": "/static/*",
"cofaxTools": "/tools/*"},
"taglib": {
"taglib-uri": "cofax.tld",
"taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
The same file expressed as XML:
cofaxCDS
org.cofax.cds.CDSServlet
configGlossary:installationAt
Philadelphia, PA
configGlossary:adminEmail
ksm@pobox.com
configGlossary:poweredBy
Cofax
configGlossary:poweredByIcon
/images/cofax.gif
configGlossary:staticPath
/content/static
templateProcessorClass
org.cofax.WysiwygTemplate
templateLoaderClass
org.cofax.FilesTemplateLoader
templatePath
templates
templateOverridePath
defaultListTemplate
listTemplate.htm
defaultFileTemplate
articleTemplate.htm
useJSP
false
jspListTemplate
listTemplate.jsp
jspFileTemplate
articleTemplate.jsp
cachePackageTagsTrack
200
cachePackageTagsStore
200
cachePackageTagsRefresh
60
cacheTemplatesTrack
100
cacheTemplatesStore
50
cacheTemplatesRefresh
15
cachePagesTrack
200
cachePagesStore
100
cachePagesRefresh
10
cachePagesDirtyRead
10
searchEngineListTemplate
forSearchEnginesList.htm
searchEngineFileTemplate
forSearchEngines.htm
searchEngineRobotsDb
WEB-INF/robots.db
useDataStore
true
dataStoreClass
org.cofax.SqlDataStore
redirectionClass
org.cofax.SqlRedirection
dataStoreName
cofax
dataStoreDriver
com.microsoft.jdbc.sqlserver.SQLServerDriver
dataStoreUrl
jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon
dataStoreUser
sa
dataStorePassword
dataStoreTestQuery
SET NOCOUNT ON;select test='test';
dataStoreLogFile
/usr/local/tomcat/logs/datastore.log
dataStoreInitConns
10
dataStoreMaxConns
100
dataStoreConnUsageLimit
100
dataStoreLogLevel
debug
maxUrlLength
500
cofaxEmail
org.cofax.cds.EmailServlet
mailHost
mail1
mailHostOverride
mail2
cofaxAdmin
org.cofax.cds.AdminServlet
fileServlet
org.cofax.cds.FileServlet
cofaxTools
org.cofax.cms.CofaxToolsServlet
templatePath
toolstemplates/
log
1
logLocation
/usr/local/tomcat/logs/CofaxTools.log
logMaxSize
dataLog
1
dataLogLocation
/usr/local/tomcat/logs/dataLog.log
dataLogMaxSize
removePageCache
/content/admin/remove?cache=pages&id=
removeTemplateCache
/content/admin/remove?cache=templates&id=
fileTransferFolder
/usr/local/tomcat/webapps/content/fileTransferFolder
lookInContext
1
adminGroupID
4
betaServer
true
cofaxCDS
/
cofaxEmail
/cofaxutil/aemail/*
cofaxAdmin
/admin/*
fileServlet
/static/*
cofaxTools
/tools/*
cofax.tld
/WEB-INF/tlds/cofax.tld
The action and label values only need to be provided if they are not the same as the id.
{"menu": {
"header": "SVG Viewer",
"items": [
{"id": "Open"},
{"id": "OpenNew", "label": "Open New"},
null,
{"id": "ZoomIn", "label": "Zoom In"},
{"id": "ZoomOut", "label": "Zoom Out"},
{"id": "OriginalView", "label": "Original View"},
null,
{"id": "Quality"},
{"id": "Pause"},
{"id": "Mute"},
null,
{"id": "Find", "label": "Find..."},
{"id": "FindAgain", "label": "Find Again"},
{"id": "Copy"},
{"id": "CopyAgain", "label": "Copy Again"},
{"id": "CopySVG", "label": "Copy SVG"},
{"id": "ViewSVG", "label": "View SVG"},
{"id": "ViewSource", "label": "View Source"},
{"id": "SaveAs", "label": "Save As"},
null,
{"id": "Help"},
{"id": "About", "label": "About Adobe CVG Viewer..."}
]
}}
The same message expressed as XML:
We have discussed qsort() in C. C++ STL provides a similar function sort that sorts a vector or array (items with random access)
It generally takes two parameters, the first one being the point of the array/vector from where the sorting needs to begin and the second parameter being the length up to which we want the array/vector to get sorted. The third parameter is optional and can be used in cases such as if we want to sort the elements lexicographically.
By default, the sort() function sorts the elements in ascending order.
Below is a simple program to show the working of sort().
// C++ program to demonstrate default behaviour of
// sort() in STL.
#include
using namespace std;
int main()
{
int arr[] = { 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
int n = sizeof(arr) / sizeof(arr[0]);
/*Here we take two parameters, the beginning of the
array and the length n upto which we want the array to
be sorted*/
sort(arr, arr + n);
cout << "\nArray after sorting using "
"default sort is : \n";
for (int i = 0; i < n; ++i)
cout << arr[i] << " ";
return 0;
}
Output
Array after sorting using default sort is :
0 1 2 3 4 5 6 7 8 9
Time Complexity: O(N log N)
Auxiliary Space: O(1)
How to sort in descending order?
sort() takes a third parameter that is used to specify the order in which elements are to be sorted. We can pass the “greater()” function to sort in descending order. This function does a comparison in a way that puts greater elements before.
// C++ program to demonstrate descending order sort using
// greater<>().
#include
using namespace std;
int main()
{
int arr[] = { 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
int n = sizeof(arr) / sizeof(arr[0]);
sort(arr, arr + n, greater());
cout << "Array after sorting : \n";
for (int i = 0; i < n; ++i)
cout << arr[i] << " ";
return 0;
}
Output
Array after sorting :
9 8 7 6 5 4 3 2 1 0
Time Complexity: O(N log N)
Auxiliary Space: O(1)
Sort the array only in the given range: To deal with such types of problems we just have to mention the range inside the sort function.
Below is the implementation of above case:
// C++ program to demonstrate sort()
#include
using namespace std;
int main()
{
int arr[] = { 0, 1, 5, 8, 9, 6, 7, 3, 4, 2 };
int n = sizeof(arr) / sizeof(arr[0]);
// Sort the elements which lies in the range of 2 to
// (n-1)
sort(arr + 2, arr + n);
cout << "Array after sorting : \n";
for (int i = 0; i < n; ++i)
cout << arr[i] << " ";
return 0;
}
// This code is contributed by Suruchi Kumari
Output
Array after sorting :
0 1 2 3 4 5 6 7 8 9
Time Complexity: O(N log N)
Auxiliary Space: O(1)
How to sort in a particular order?
We can also write our own comparator function and pass it as a third parameter. This “comparator” function returns a value; convertible to bool, which basically tells us whether the passed “first” argument should be placed before the passed “second” argument or not.
For eg: In the code below, suppose intervals {6,8} and {1,9} are passed as arguments in the “compareInterval” function(comparator function). Now as i1.first (=6) < i2.first (=1), so our function returns “false”, which tells us that “first” argument should not be placed before “second” argument and so sorting will be done in order like {1,9} first and then {6,8} as next.
// A C++ program to demonstrate
// STL sort() using
// our own comparator
#include
using namespace std;
// An interval has a start
// time and end time
struct Interval {
int start, end;
};
// Compares two intervals
// according to starting times.
bool compareInterval(Interval i1, Interval i2)
{
return (i1.start < i2.start);
}
int main()
{
Interval arr[]
= { { 6, 8 }, { 1, 9 }, { 2, 4 }, { 4, 7 } };
int n = sizeof(arr) / sizeof(arr[0]);
// sort the intervals in increasing order of
// start time
sort(arr, arr + n, compareInterval);
cout << "Intervals sorted by start time : \n";
for (int i = 0; i < n; i++)
cout << "[" << arr[i].start << "," << arr[i].end
<< "] ";
return 0;
}
Output
Intervals sorted by start time :
[1,9] [2,4] [4,7] [6,8]
The time complexity of std::sort() is:
Best Case – O(N log N)
Average Case – O(N log N)
Worst-Case – O(N log N)
Space Complexity: It may use O( log N) auxiliary space.
#include
#include
using namespace std;
template
class Comparator { // we pass an object of this class as
// third arg to sort function...
public:
bool operator()(T x1, T x2)
{
return x1 < x2;
}
};
template bool funComparator(T x1, T x2)
{ // return type is bool
return x1 <= x2;
}
void show(int a[], int array_size)
{
for (int i = 0; i < array_size; i++) {
cout << a[i] << " ";
}
}
int main()
{
int a[] = { 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
int asize = sizeof(a) / sizeof(int);
cout << "The array before sorting is : ";
show(a, asize);
cout << endl << "The array after sorting is(asc) :";
sort(a, a + asize);
show(a, asize);
cout << endl << "The array after sorting is(desc) :";
sort(a, a + asize, greater());
show(a, asize);
cout << endl
<< "The array after sorting is(asc but our "
"comparator class) :";
sort(a, a + asize, Comparator());
show(a, asize);
cout << endl
<< "The array after sorting is(asc but our "
"comparator function) :";
sort(a, a + asize, funComparator);
show(a, asize);
return 0;
}
Output
The array before sorting is : 1 5 8 9 6 7 3 4 2 0
The array after sorting is(asc) :0 1 2 3 4 5 6 7 8 9
The array after sorting is(desc) :9 8 7 6 5 4 3 2 1 0
The array after sorting is(asc but our comparator class) :0 1 2 3 4 5 6 7 8 9
The array after sorting is(asc but our comparator function) :0 1 2 3 4 5 6 7 8 9
Time Complexity: O(N log N)
Auxiliary Space: O(1)
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
The following are different ways to construct or initialize a vector in C++ STL
1. Initializing by pushing values one by one:
// C++ program to create an empty
// vector and push values one
// by one.
#include
#include
using namespace std;
int main()
{
// Create an empty vector
vector vect;
vect.push_back(10);
vect.push_back(20);
vect.push_back(30);
for (int x : vect)
cout << x << " ";
return 0;
}
Output
10 20 30
2. Specifying size and initializing all values:
// C++ program to create an empty
// vector and push values one
// by one.
#include
#include
using namespace std;
int main()
{
int n = 3;
// Create a vector of size n with
// all values as 10.
vector vect(n, 10);
for (int x : vect)
cout << x << " ";
return 0;
}
Output
10 10 10
3. Initializing like arrays:
// C++ program to initialize
// a vector like an array.
#include
#include
using namespace std;
int main()
{
vector vect{ 10, 20, 30 };
for (int x : vect)
cout << x << " ";
return 0;
}
Output
10 20 30
4. Initializing from an array:
// C++ program to initialize
// a vector from an array.
#include
#include
using namespace std;
int main()
{
int arr[] = { 10, 20, 30 };
int n = sizeof(arr) / sizeof(arr[0]);
vector vect(arr, arr + n);
for (int x : vect)
cout << x << " ";
return 0;
}
Output
10 20 30
5. Initializing from another vector:
// C++ program to initialize a vector from
// another vector.
#include
#include
using namespace std;
int main()
{
vector vect1{ 10, 20, 30 };
vector vect2(vect1.begin(), vect1.end());
for (int x : vect2)
cout << x << " ";
return 0;
}
Output
10 20 30
6. Initializing all elements with a particular value:
// C++ Program to initialize vector using fill()
#include
#include
using namespace std;
int main()
{
// creating array with size 10
vector vect1(10);
// initializing using fill() function
int value = 5;
fill(vect1.begin(), vect1.end(), value);
// printing vector
for (int x : vect1)
cout << x << " ";
return 0;
}
Output
5 5 5 5 5 5 5 5 5 5
7. Initialize an array with consecutive numbers using std::iota:
// C++ program to initialize a
// vector with consecutive
// numbers
#include
#include
#include
using namespace std;
int main()
{
// declaring a vector with size 5
vector vec(5);
// initializing using iota()
iota(vec.begin(), vec.end(), 1);
// printing the vector
for (int i = 0; i < 5; i++) {
cout << vec[i] << " ";
}
return 0;
}
Output
1 2 3 4 5
Time complexity: O(N), where N is the size of the vector.
Auxiliary space: O(N).
If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!
How to Hide and Show a Console Window in C++?
Read
Discuss
Courses
Practice
The task is to hide and Show the console window of a C++ program. The program for the same is given below.
Note: The results of the following program can only be seen when it is executed on a console.
Example:
// C++ program to hide and show a console window
#include
#include
using namespace std;
void countdown()
{
cout << "3" << endl;
Sleep(1000);
cout << "2" << endl;
Sleep(1000);
cout << "1" << endl;
Sleep(1000);
cout << "0" << endl;
}
int main()
{
countdown();
HWND window;
AllocConsole();
// You Can Find HANDLE of other windows too
window = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(window, 0);
countdown();
ShowWindow(window, 1);
}
Output:
Explanation: The above program counts from 3 to 1 before the Console Window disappears. After the window has disappeared, the ShowWindow helps the program so that the Console Window reappears again after counting from 3 to 1(executing the countdown function).
The execution of the program can be understood by understanding the key functions of the program.
#include – The windows.h header in C++ programming languages are specifically designed for windows and contain a very large number of windows specific functions.
AllocConsole()- AllocConsole initializes standard input, standard output, and standard error handles for the new console.
ShowWindow()- Sets the specified window’s show state.
FindWindowA()– Takes string parameters and checks whose class name and window name match the specified strings
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!
Last Updated : 27 Nov, 2022
Prerequisite: Templates in C++
Substitution Failure Is Not An Error (SFINAE) is a principle of the C++ programming language that states that a compiler should not fail to compile a program just because it cannot substitute a template parameter. This principle allows for the use of template metaprogramming and enables the compiler to make decisions based on the types of template arguments, which can be useful when dealing with complex code and difficult to reason about logic.
At its core, SFINAE is a way of allowing a compiler to decide which template to use in a given context. The decision is based on the types of template arguments and the compiler will choose the template that is most appropriate for the arguments.
Advantages of SFINAE:
SFINAE is useful in a variety of scenarios, including writing generic code and dealing with complex logic.
SFINAE allows the compiler to decide which template to use, it allows programmers to write code that can be reused in different contexts without needing to explicitly specify the types of template parameters.
SFINAE allows for better code reuse, as the same code can be used for different types of objects and parameters.
SFINAE also allows for better control over code complexity by allowing the compiler to make decisions based on the types of template parameters, it can reduce the amount of complex logic that needs to be written and understood.
SFINAE helps to make code more readable and maintainable, as it is easier to follow the logic of the program.
In conclusion, SFINAE is a powerful concept in C++ programming that allows for better code reuse, improved code readability, and better control over code complexity. It is a key component of template metaprogramming and is an essential tool for writing robust and efficient code.
Example:
// C++ Program to implement
// Substitution Failure Is Not An Error
#include
#include
using namespace std;
// USing template to avoid errors
template
void print_type(T t)
{
// For integer
if (is_integral::value) {
cout << "T is an integral type" << endl;
}
// For floating number
else if (is_floating_point::value) {
cout << "T is a floating point type" << endl;
}
// All other
else {
cout << "T is not an integral"
<< "or floating point type" << endl;
}
}
// Driver Code
int main()
{
// T is an integral type
print_type(10);
// T is a floating point type
print_type(10.5f);
// T is an integral type
print_type(true);
// T is an integral type
print_type('a');
// T is not an integral
// or floating point type
print_type("GFG");
return 0;
}
Output
T is an integral type
T is a floating point type
T is an integral type
T is an integral type
T is not an integralor floating point type
In this example, the print_type() function is a template function that takes a single argument of type T. Inside the function, there are if statements that use the is_integral and is_floating_point type traits to check the type of T. If T is of the expected type, the corresponding branch of the if statement is executed and the appropriate message is printed. If T is not of the expected type, the else branch is executed and the message “T is not an integral or floating point type” is printed.
SFINAE is used in this example because the if statement uses type traits to check the type of T, and if T is not of the expected type, the template substitution will fail. However, because SFINAE is in effect, this failure is not treated as a compile-time error, and the else branch is executed instead.
Disadvantages of SFINAE
Although SFINAE is very useful it comes with its own limitations, these are :
It can be difficult to debug and understand the underlying code, as it relies heavily on the templates and multiple overloads to work correctly.
SFINAE is not widely used and can be difficult to find documentation and tutorials for.
SFINAE can produce unexpected behavior, as it relies on the compiler to determine which template to use based on the given types. This can lead to unexpected results if the compiler chooses the wrong template.
SFINAE can also be slow, as it involves multiple checks in order to determine the correct template. This can lead to a performance hit if used in a critical section of code.
There are other methods to perform the same task one of which is enable_if
Enable_if (Syntax)
template
enable_if_t, void> f(T x)
{
// code that only applies to integral tmodule jinvertertb;
reg a;
wire y;
//Design Instance
jinverter jinv(y,a);
initial
begin
$display ("RESULT\ta\ty");
a = 1; # 100; // Another value
if ( y == 0 ) // Test for inversion
$display (" PASS \t%d\t%d",a,y);
else
$display (" FAIL \t%d\t%d",a,y);
a = 0; # 100; // Initial value is set
if ( y == 1 ) // Test for inversion
$display (" PASS \t%d\t%d",a,y);
else
$display (" FAIL \t%d\t%d",a,y);
a = 1; # 50; // Another value
if ( y == 0 ) // Test for inversion
$display (" PASS \t%d\t%d",a,y);
else
$display (" FAIL \t%d\t%d",a,y);
a = 0; # 100; // Initial value is set
if ( y == 1 ) // Test for inversion
$display (" PASS \t%d\t%d",a,y);
else
$display (" FAIL \t%d\t%d",a,y);
end
//enabling the wave dump
initial begin
$dumpfile("dump.vcd"); $dumpvars;
end
endmoduleypes goes here
}
module jinvertertb;
reg a;
wire y;
//Design Instance
jinverter jinv(y,a);
initial
begin
$display ("RESULT\ta\ty");
a = 1; # 100; // Another value
if ( y == 0 ) // Test for inversion
$display (" PASS \t%d\t%d",a,y);
else
$display (" FAIL \t%d\t%d",a,y);
a = 0; # 100; // Initial value is set
if ( y == 1 ) // Test for inversion
$display (" PASS \t%d\t%d",a,y);
else
$display (" FAIL \t%d\t%d",a,y);
a = 1; # 50; // Another value
if ( y == 0 ) // Test for inversion
$display (" PASS \t%d\t%d",a,y);
else
$display (" FAIL \t%d\t%d",a,y);
a = 0; # 100; // Initial value is set
if ( y == 1 ) // Test for inversion
$display (" PASS \t%d\t%d",a,y);
else
$display (" FAIL \t%d\t%d",a,y);
end
//enabling the wave dump
initial begin
$dumpfile("dump.vcd"); $dumpvars;
end
endmodule
module jFIFOTb;
wire [7:0] DATAOUT;
wire full, empty;
reg clock, reset, wn, rn;
reg [7:0] DATAIN;
jFIFO jfifo(DATAOUT, full, empty, clock, reset, wn, rn, DATAIN);
//enabling the wave dump
initial begin
$dumpfile("dump.vcd"); $dumpvars;
end
initial
begin
clock = 0; DATAIN = 8'd0;
reset = 1; clock = 1; #5 ; clock = 0; #5;
reset = 0;
$display("Start testing");
// First write some data into the queue
wn = 1; rn = 0;
DATAIN = 8'd100;
clock = 1; #5 ; clock = 0; #5;
DATAIN = 8'd150;
clock = 1; #5 ; clock = 0; #5;
DATAIN = 8'd200;
clock = 1; #5 ; clock = 0; #5;
DATAIN = 8'd40;
clock = 1; #5 ; clock = 0; #5;
DATAIN = 8'd70;
clock = 1; #5 ; clock = 0; #5;
DATAIN = 8'd65;
clock = 1; #5 ; clock = 0; #5;
DATAIN = 8'd15;
clock = 1; #5 ; clock = 0; #5;
// Now start reading and checking the values
wn = 0; rn = 1;
clock = 1; #5 ; clock = 0; #5;
if ( DATAOUT === 8'd100 )
$display("PASS %p ", DATAOUT);
else
$display("FAIL %p ", DATAOUT);
clock = 1; #5 ; clock = 0; #5;
if ( DATAOUT === 8'd150 )
$display("PASS %p ", DATAOUT);
else
$display("FAIL %p ", DATAOUT);
clock = 1; #5 ; clock = 0; #5;
if ( DATAOUT === 8'd200 )
$display("PASS %p ", DATAOUT);
else
$display("FAIL %p ", DATAOUT);
clock = 1; #5 ; clock = 0; #5;
if ( DATAOUT === 8'd40 )
$display("PASS %p ", DATAOUT);
else
$display("FAIL %p ", DATAOUT);
clock = 1; #5 ; clock = 0; #5;
if ( DATAOUT === 8'd70 )
$display("PASS %p ", DATAOUT);
else
$display("FAIL %p ", DATAOUT);
clock = 1; #5 ; clock = 0; #5;
if ( DATAOUT === 8'd65 )
$display("PASS %p ", DATAOUT);
else
$display("FAIL %p ", DATAOUT);
clock = 1; #5 ; clock = 0; #5;
if ( DATAOUT === 8'd15 )
$display("PASS %p ", DATAOUT);
else
$display("FAIL %p ", DATAOUT);
clock = 1; #5 ; clock = 0; #5;
if ( empty === 1 )
$display("PASS %p ", empty);
else
$display("FAIL %p ", empty);
end
endmodule
To understand this example, you should have the knowledge of the following Java programming topics:
Java for Loop
Java while and do...while Loop
The factorial of a positive number n is given by:
factorial of n (n!) = 1 * 2 * 3 * 4 * ... * n
Example 1: Find Factorial of a number using for loop
public class Factorial {
public static void main(String[] args) {
int num = 10;
long factorial = 1;
for(int i = 1; i <= num; ++i)
{
// factorial = factorial * i;
factorial *= i;
}
System.out.printf("Factorial of %d = %d", num, factorial);
}
}
Output
Factorial of 10 = 3628800
In this program, we've used for loop to loop through all numbers between 1 and the given number num (10), and the product of each number till num is stored in a variable factorial.
We've used long instead of int to store large results of factorial. However, it's still not big enough to store the value of bigger numbers (say 100).
For results that cannot be stored in a long variable, we use BigInteger variable declared in java.math library.
Example 2: Find Factorial of a number using BigInteger
import java.math.BigInteger;
public class Factorial {
public static void main(String[] args) {
int num = 30;
BigInteger factorial = BigInteger.ONE;
for(int i = 1; i <= num; ++i)
{
// factorial = factorial * i;
factorial = factorial.multiply(BigInteger.valueOf(i));
}
System.out.printf("Factorial of %d = %d", num, factorial);
}
}
Output
Factorial of 30 = 265252859812191058636308480000000
Here, instead of long, we use BigInteger variable factorial.
Since, * cannot be used with BigInteger, we instead use multiply() for the product. Also, num should be casted to BigInteger for multiplication.
Likewise, we can also use a while loop to solve this problem.
Example 3: Find Factorial of a number using while loop
public class Factorial {
public static void main(String[] args) {
int num = 5, i = 1;
long factorial = 1;
while(i <= num)
{
factorial *= i;
i++;
}
System.out.printf("Factorial of %d = %d", num, factorial);
}
}
Output
Factorial of 5 = 120
In the above program, unlike a for loop, we have to increment the value of i inside the body of the loop.
Though both programs are technically correct, it is better to use for loop in this case. It's because the number of iteration (upto num) is known.
Visit this page to learn to find factorial of a number using recursion.
Java Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers
To understand this example, you should have the knowledge of the following Java programming topics:
Java Methods
Java for Loop
Java if...else Statement
Example: Represent a number as Sum of Two Prime Numbers
public class Main {
public static void main(String[] args) {
int number = 34;
boolean flag = false;
for (int i = 2; i <= number / 2; ++i) {
// condition for i to be a prime number
if (checkPrime(i)) {
// condition for n-i to be a prime number
if (checkPrime(number - i)) {
// n = primeNumber1 + primeNumber2
System.out.printf("%d = %d + %d\n", number, i, number - i);
flag = true;
}
}
}
if (!flag)
System.out.println(number + " cannot be expressed as the sum of two prime numbers.");
}
// Function to check prime number
static boolean checkPrime(int num) {
boolean isPrime = true;
for (int i = 2; i <= num / 2; ++i) {
if (num % i == 0) {
isPrime = false;
break;
}
}
return isPrime;
}
}
Run Code
Output
34 = 3 + 31
34 = 5 + 29
34 = 11 + 23
34 = 17 + 17
In the above example, we have created the checkPrime() method to find whether a number is prime or not. The method returns true if the passed number is prime.
Here, we have a number 34. The program tries to check if 34 can be represented as the sum of two prime numbers.
Working of Program
First, we run a for loop from i = 2 to number / 2.
Inside the for loop, we used two if statements. The first statement checks if i is prime or not.
If true, the second if statement checks if number - i is prime or not. This is because the sum of i and number - i is equal to number.
If the second statement is also true, then we can say the number 34 is a valid sum of two prime numbers.
// Java Program to Check if Given Integer is Odd or Even
// Using Brute Forcew Approach
// Importing required classes
import java.io.*;
import java.util.Scanner;
// Main class
class GFG {
// Main Driver Method
public static void main(String[] args)
{
// Declaring and initializing integer variable
int num = 10;
// Checking if number is even or odd number
// via remainder
if (num % 2 == 0) {
// If remainder is zero then this number is even
System.out.println("Entered Number is Even");
}
else {
// If remainder is not zero then this number is
// odd
System.out.println("Entered Number is Odd");
}
}
}
// Java Program to find even sum of
// fibonacci Series Till number N
import java.io.*;
class geeksforgeeks {
// Computing the value of first fibonacci series
// and storing the sum of even indexed numbers
static int Fib_Even_Sum(int N)
{
if (N <= 0)
return 0;
int fib[] = new int[2 * N + 1];
fib[0] = 0;
fib[1] = 1;
// Initializing the sum
int s = 0;
// Adding remaining numbers
for (int j = 2; j <= 2 * N; j++) {
fib[j] = fib[j - 1] + fib[j - 2];
// Only considering even indexes
if (j % 2 == 0)
s += fib[j];
}
return s;
}
// The Driver code
public static void main(String[] args)
{
int N = 11;
// Prints the sum of even-indexed numbers
System.out.println(
"Even sum of fibonacci series till number " + N
+ " is: " + +Fib_Even_Sum(N));
}
}
It can be clearly seen that the required sum can be obtained thus:
2 ( F2 + F4 + F6 +………+ F2n ) = (F1 + F2 + F3 + F4 +………+ F2n) – (F1 – F2 + F3 – F4 +………+ F2n)
Now the first term can be obtained if we put 2n instead of n in the formula given here.
Thus F1 + F2 + F3 + F4 +………+ F2n = F2n+2 – 1.
The second term can also be found if we put 2n instead of n in the formula given here
Thus, F1 – F2 + F3 – F4 +………- F2n = 1 + (-1)2n+1F2n-1 = 1 – F2n-1.
So, 2 ( F2 + F4 + F6 +………+ F2n)
= F2n+2 – 1 – 1 + F2n-1
= F2n+2 + F2n-1 – 2
= F2n + F2n+1 + F2n+1 – F2n – 2
= 2 ( F2n+1 -1)
Hence, ( F2 + F4 + F6 +………+ F2n) = F2n+1 -1 .
// Java Program to find even indexed
// Fibonacci Sum in O(Log n) time.
class GFG {
static int MAX = 1000;
// Create an array for memoization
static int f[] = new int[MAX];
// Returns n'th Fibonacci number
// using table f[]
static int fib(int n)
{
// Base cases
if (n == 0) {
return 0;
}
if (n == 1 || n == 2) {
return (f[n] = 1);
}
// If fib(n) is already computed
if (f[n] == 1) {
return f[n];
}
int k = (n % 2 == 1) ? (n + 1) / 2 : n / 2;
// Applying above formula [Note value n&1 is 1
// if n is odd, else 0].
f[n] = (n % 2 == 1)
? (fib(k) * fib(k)
+ fib(k - 1) * fib(k - 1))
: (2 * fib(k - 1) + fib(k)) * fib(k);
return f[n];
}
// Computes value of even-indexed Fibonacci Sum
static int calculateEvenSum(int n)
{
return (fib(2 * n + 1) - 1);
}
// Driver program to test above function
public static void main(String[] args)
{
// Get n
int n = 11;
// Find the alternating sum
System.out.println(
"Even indexed Fibonacci Sum upto " + n
+ " terms: " + calculateEvenSum(n));
}
}
SCREEN 13
z = 1 / 100
FOR i = 0 TO 255
PALETTE i, INT(i / 4) + INT(i / 4) * 256 + INT(i / 4) * 65536
NEXT
DO
y = 1
dy = 0
ox = 0: oy = 1
FOR x = 1 TO 430
IF y > 0 THEN dy = dy - 1 / 4000
IF y < 0 THEN dy = dy + z
y = y + dy
a = POINT(x, 100 + y * 50)
a = a + 1
IF a > 255 THEN a = 255
PSET (x, 100 + y * 50), a
NEXT
z = z - 1 / 10000
LOOP
DIM bodyx(70)
DIM bodyy(70)
DIM bodyvx(70)
DIM bodyvy(70)
DIM obodyx(70)
DIM obodyy(70)
RANDOMIZE TIMER
bodies = 30
FOR i = 1 TO bodies
bodyx(i) = 620 * RND + 10
bodyy(i) = 400 * RND + 30
bodyvx(i) = RND - .5
bodyvy(i) = RND - .5
NEXT
SCREEN 12
PRINT "...."
WHILE INKEY$ = "": WEND
CLS
DO
' apply gravity
FOR i = 1 TO bodies
bodyvy(i) = bodyvy(i) + .001
NEXT
' adjust distances
FOR i = 1 TO bodies
FOR j = 1 TO bodies
IF i <> j THEN
centx = (bodyx(i) + bodyx(j)) * .5
centy = (bodyy(i) + bodyy(j)) * .5
distx = (bodyx(i) - bodyx(j)) / 2
disty = (bodyy(i) - bodyy(j)) / 2
distf = SQR(distx * distx + disty * disty)
mx = distx / distf
my = disty / distf
bodyvx(i) = bodyvx(i) - mx * (distf - 50) / 100
bodyvy(i) = bodyvy(i) - my * (distf - 50) / 100
END IF
NEXT
NEXT
' collide with ground
FOR i = 1 TO bodies
IF bodyy(i) + bodyvy(i) > 440 OR bodyy(i) + bodyvy(i) < 5 THEN
bodyvy(i) = -bodyvy(i) * 0!
bodyvx(i) = bodyvx(i) * 0!
END IF
IF bodyx(i) + bodyvx(i) > 625 OR bodyx(i) + bodyvx(i) < 15 THEN
bodyvx(i) = -bodyvx(i) * 0!
bodyvy(i) = bodyvy(i) * 0!
END IF
NEXT
' move bodies
FOR i = 1 TO bodies
obodyx(i) = bodyx(i)
obodyy(i) = bodyy(i)
bodyx(i) = bodyx(i) + bodyvx(i)
bodyy(i) = bodyy(i) + bodyvy(i)
NEXT
' clear/draw
q = (q + 1) MOD 16
FOR i = 1 TO bodies
COLOR 0
CIRCLE (obodyx(i), obodyy(i)), 4
COLOR 15
CIRCLE (bodyx(i), bodyy(i)), 4
'COLOR q
'LINE (bodyx(i), bodyy(i))-(bodyx(i) + bodyvx(i) * 30, bodyy(i) + bodyvy(i) * 30)
NEXT
COLOR 2
LINE (obodyx(1), obodyy(1))-(bodyx(1), bodyy(1))
'FOR i = 1 TO bodies - 1
' FOR j = i + 1 TO bodies
' COLOR 0
' LINE (obodyx(i), obodyy(i))-(obodyx(j), obodyy(j))
' COLOR 2
' LINE (bodyx(i), bodyy(i))-(bodyx(j), bodyy(j))
' NEXT
'NEXT
LOOP
;---------------------------------------------------------------------------
; start
;---------------------------------------------------------------------------
start
desc
msg "It's a room."
objects
start/key
start/door
start/key
id "key"
desc
msg "It's a key."
actions
use door
ifn start/door.flags.locked
msg "The door isn't locked."
if start/door.flags.locked
msg "The lock on the door goes 'click'."
set start/door.flags.locked false
examine
msg "It is shiny."
start/door
id "door"
desc
msg "You see a door."
flags
locked true
open false
actions
open
if start/door.flags.locked
msg "It is locked."
ifn start/door.flags.locked
msg "The door opens."
close
ifn start/door.flags.open
msg "It is already closed."
if start/door.flags.open
msg "The door closes."
go
if start/door.flags.open
goto end
ifn start/door.flags.open
msg "The door is closed."
examine
msg "It looks just like a door."
;---------------------------------------------------------------------------
; end
;---------------------------------------------------------------------------
end
desc
"Congratimafations! Another room."
objects
start/door
macroScript ExportCamera category:"Cameras" toolTip:"Blech!" Icon:#("Cameras",2)
(
filename = maxFileName
flen = findString filename ".max"
filename = substring filename 1 (flen-1)
sname = filename
filename = maxFilePath + filename + ".piper3d"
deletefile filename
out_file = createfile filename
format ";------------------------------------------------------------\n" to:out_file
format "; Piper 3D scene file\n" to:out_file
format ";\n" to:out_file
format "; Scene: % \n" sname to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "\n" to:out_file
format "%_begin\n" sname to:out_file
format "\n" to:out_file
animend = animationRange.end as string
animend = substring animend 1 (findString animend "f"-1)
format " dc.w % ; no. frames\n" animend to:out_file
format " dc.w % ; no. objects\n" objects.count to:out_file
faces = 0
vertices = 0
for o in objects do (
if classOf o == Editable_Mesh then (
faces += o.numfaces
vertices += o.numverts
)
)
format " dc.w % ; no. vertices\n" vertices to:out_file
format " dc.w % ; no. faces\n" faces to:out_file
format "\n" to:out_file
format " dc.w 0 ; current frame\n" to:out_file
format "\n" to:out_file
format " dc.l %_vtx ; begin vertices\n" sname sname to:out_file
format " dc.l %_fcs ; begin fæces\n" sname sname to:out_file
format " dc.l %_mtx ; begin matrices\n" sname sname to:out_file
format " dc.l 0 ; begin vertex normals\n" to:out_file
format "\n" to:out_file
format " dc.w 0 ; init flag\n" to:out_file
format "\n" to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "; Vertex groups\n" to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "\n" to:out_file
format "%_vtx\n" sname to:out_file
format "\n" to:out_file
for i=1 to objects.count do (
format "; group %: %\n" (i-1) objects[i].name to:out_file
format "\n" to:out_file
if classOf objects[i] == Editable_Mesh then (
obimat = (inverse objects[i].transform)
themesh = snapshotAsMesh objects[i]
format " dc.w % ; no. vertices\n" themesh.numverts to:out_file
for j=1 to themesh.numverts do (
v = (getVert themesh j) * obimat
vxs = formatf v.x 6
vys = formatf v.y 6
vzs = formatf v.z 6
format " dc.s %,%,%\n" vxs vys vzs to:out_file
)
) else (
format " dc.w 0 ; not a mesh\n" to:out_file
)
format "\n" to:out_file
)
format ";------------------------------------------------------------\n" to:out_file
format "; Fæces\n" to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "\n" to:out_file
format "%_fcs\n" sname to:out_file
format "\n" to:out_file
voff = 0
for i=1 to objects.count do (
format "; group %: %\n" (i-1) objects[i].name to:out_file
format "\n" to:out_file
if classOf objects[i] == Editable_Mesh then (
themesh = snapshotAsMesh objects[i]
for j=1 to themesh.numfaces do (
f = getFace themesh j
format " dc.w %,%,%\n" (int (f.x-1+voff)) (int (f.y-1+voff)) (int (f.z-1+voff)) to:out_file
smat = objects[i].material
mattype = "0"
u1 = 0
v1 = 0
u2 = 0
v2 = 0
u3 = 0
v3 = 0
if smat == undefined then (
matname = "0"
) else (
if getNumSubMtls smat == 0 then (
mat = smat
) else (
matid = getFaceMatID themesh j
mat = smat.MaterialList[matid]
)
matname = (int mat.diffuse.r)*256*256 + (int mat.diffuse.g)*256 + (int mat.diffuse.b)
dmap = mat.diffuseMap
if dmap != undefined then (
mattype = "1"
matname = dmap.filename
fntokens = filterString matname "\\"
matname = fntokens[fntokens.count]
fntokens = filterString matname "."
matname = fntokens[1]
fntokens = filterString matname "-"
matname = ""
for k=1 to fntokens.count do (
matname = matname + fntokens[k]
if k < fntokens.count then matname=matname+"m"
)
matname = sname + "_" + matname + "+1024+14"
tverts = getTVFace theMesh j
u1 = (int (getTVert theMesh tverts[1] * 65535).x)
v1 = 65535 - (int (getTVert theMesh tverts[1] * 65535).y)
u2 = (int (getTVert theMesh tverts[2] * 65535).x)
v2 = 65536 - (int (getTVert theMesh tverts[2] * 65535).y)
macroScript ExportCamera category:"Cameras" toolTip:"Blech!" Icon:#("Cameras",2)
(
filename = maxFileName
flen = findString filename ".max"
filename = substring filename 1 (flen-1)
sname = filename
filename = maxFilePath + filename + ".piper3d"
deletefile filename
out_file = createfile filename
format ";------------------------------------------------------------\n" to:out_file
format "; Piper 3D scene file\n" to:out_file
format ";\n" to:out_file
format "; Scene: % \n" sname to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "\n" to:out_file
format "%_begin\n" sname to:out_file
format "\n" to:out_file
animend = animationRange.end as string
animend = substring animend 1 (findString animend "f"-1)
format " dc.w % ; no. frames\n" animend to:out_file
format " dc.w % ; no. objects\n" objects.count to:out_file
faces = 0
vertices = 0
for o in objects do (
if classOf o == Editable_Mesh then (
faces += o.numfaces
vertices += o.numverts
)
)
format " dc.w % ; no. vertices\n" vertices to:out_file
format " dc.w % ; no. faces\n" faces to:out_file
format "\n" to:out_file
format " dc.w 0 ; current frame\n" to:out_file
format "\n" to:out_file
format " dc.l %_vtx ; begin vertices\n" sname sname to:out_file
format " dc.l %_fcs ; begin fæces\n" sname sname to:out_file
format " dc.l %_mtx ; begin matrices\n" sname sname to:out_file
format " dc.l 0 ; begin vertex normals\n" to:out_file
format "\n" to:out_file
format " dc.w 0 ; init flag\n" to:out_file
format "\n" to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "; Vertex groups\n" to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "\n" to:out_file
format "%_vtx\n" sname to:out_file
format "\n" to:out_file
for i=1 to objects.count do (
format "; group %: %\n" (i-1) objects[i].name to:out_file
format "\n" to:out_file
if classOf objects[i] == Editable_Mesh then (
obimat = (inverse objects[i].transform)
themesh = snapshotAsMesh objects[i]
format " dc.w % ; no. vertices\n" themesh.numverts to:out_file
for j=1 to themesh.numverts do (
v = (getVert themesh j) * obimat
vxs = formatf v.x 6
vys = formatf v.y 6
vzs = formatf v.z 6
format " dc.s %,%,%\n" vxs vys vzs to:out_file
)
) else (
format " dc.w 0 ; not a mesh\n" to:out_file
)
format "\n" to:out_file
)
format ";------------------------------------------------------------\n" to:out_file
format "; Fæces\n" to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "\n" to:out_file
format "%_fcs\n" sname to:out_file
format "\n" to:out_file
voff = 0
for i=1 to objects.count do (
format "; group %: %\n" (i-1) objects[i].name to:out_file
format "\n" to:out_file
if classOf objects[i] == Editable_Mesh then (
themesh = snapshotAsMesh objects[i]
for j=1 to themesh.numfaces do (
f = getFace themesh j
format " dc.w %,%,%\n" (int (f.x-1+voff)) (int (f.y-1+voff)) (int (f.z-1+voff)) to:out_file
smat = objects[i].material
mattype = "0"
u1 = 0
v1 = 0
u2 = 0
v2 = 0
u3 = 0
v3 = 0
if smat == undefined then (
matname = "0"
) else (
if getNumSubMtls smat == 0 then (
mat = smat
) else (
matid = getFaceMatID themesh j
mat = smat.MaterialList[matid]
)
matname = (int mat.diffuse.r)*256*256 + (int mat.diffuse.g)*256 + (int mat.diffuse.b)
dmap = mat.diffuseMap
if dmap != undefined then (
mattype = "1"
matname = dmap.filename
fntokens = filterString matname "\\"
matname = fntokens[fntokens.count]
fntokens = filterString matname "."
matname = fntokens[1]
fntokens = filterString matname "-"
matname = ""
for k=1 to fntokens.count do (
matname = matname + fntokens[k]
if k < fntokens.count then matname=matname+"m"
)
matname = sname + "_" + matname + "+1024+14"
tverts = getTVFace theMesh j
u1 = (int (getTVert theMesh tverts[1] * 65535).x)
v1 = 65535 - (int (getTVert theMesh tverts[1] * 65535).y)
u2 = (int (getTVert theMesh tverts[2] * 65535).x)
v2 = 65536 - (int (getTVert theMesh tverts[2] * 65535).y)
u3 = (int (getTVert theMesh tverts[3] * 65535).x)
v3 = 65536 - (int (getTVert theMesh tverts[3] * 65535).y)
if u1 > 65535 then u1 = 65535
if v1 > 65535 then v1 = 65535
if u2 > 65535 then u2 = 65535
if v2 > 65535 then v2 = 65535
if u3 > 65535 then u3 = 65535
if v3 > 65535 then v3 = 65535
/*
if u1 < 0 then u1 = 0
if v1 < 0 then v1 = 0
if u2 < 0 then u2 = 0
if v2 < 0 then v2 = 0
if u3 < 0 then u3 = 0
if v3 < 0 then v3 = 0
*/
if mat.opacityMap != undefined then (
mattype = "2"
)
)
)
format " dc.w %\n" mattype to:out_file
format " dc.l %\n" matname to:out_file
format " dc.w %,%,%,%,%,%\n" u1 v1 u2 v2 u3 v3 to:out_file
)
format "\n" to:out_file
voff += themesh.numverts
)
)
format ";------------------------------------------------------------\n" to:out_file
format "; \n" to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "\n" to:out_file
format "%_mtx\n" sname to:out_file
format "\n" to:out_file
for i = animationRange.start to animationRange.end do (
sliderTime=i
format "; index %\n" i to:out_file
format "\n" to:out_file
for j = 1 to objects.count do (
o=objects[j]
vpm=getViewTM()
tm=o.transform*vpm
tm1=tm.row1
tm2=tm.row2
tm3=tm.row3
tm4=tm.row4
tm11=formatf tm1.x 6
tm12=formatf tm1.y 6
tm13=formatf tm1.z 6
tm21=formatf tm2.x 6
tm22=formatf tm2.y 6
tm23=formatf tm2.z 6
tm31=formatf tm3.x 6
tm32=formatf tm3.y 6
tm33=formatf tm3.z 6
tm41=formatf tm4.x 6
tm42=formatf tm4.y 6
tm43=formatf tm4.z 6
format " dc.s %,%,%\n" tm11 tm12 tm13 to:out_file
format " dc.s %,%,%\n" tm21 tm22 tm23 to:out_file
format " dc.s %,%,%\n" tm31 tm32 tm33 to:out_file
format " dc.s %,%,%\n" tm41 tm42 tm43 to:out_file
format "\n" to:out_file
)
)
close out_file
shelllaunch "notepad.exe" filename
)
-- theend u3 = (int (getTVert theMesh tverts[3] * 65535).x)
v3 = 65536 - (int (getTVert theMesh tverts[3] * 65535).y)
if u1 > 65535 then u1 = 65535
if v1 > 65535 then v1 = 65535
if u2 > 65535 then u2 = 65535
if v2 > 65535 then v2 = 65535
if u3 > 65535 then u3 = 65535
if v3 > 65535 then v3 = 65535
/*
if u1 < 0 then u1 = 0
if v1 < 0 then v1 = 0
if u2 < 0 then u2 = 0
if v2 < 0 then v2 = 0
if u3 < 0 then u3 = 0
if v3 < 0 then v3 = 0
*/
if mat.opacityMap != undefined then (
mattype = "2"
)
)
)
format " dc.w %\n" mattype to:out_file
format " dc.l %\n" matname to:out_file
format " dc.w %,%,%,%,%,%\n" u1 v1 u2 v2 u3 v3 to:out_file
)
format "\n" to:out_file
voff += themesh.numverts
)
)
format ";------------------------------------------------------------\n" to:out_file
format "; \n" to:out_file
format ";------------------------------------------------------------\n" to:out_file
format "\n" to:out_file
format "%_mtx\n" sname to:out_file
format "\n" to:out_file
for i = animationRange.start to animationRange.end do (
sliderTime=i
format "; index %\n" i to:out_file
format "\n" to:out_file
for j = 1 to objects.count do (
o=objects[j]
vpm=getViewTM()
tm=o.transform*vpm
tm1=tm.row1
tm2=tm.row2
tm3=tm.row3
tm4=tm.row4
tm11=formatf tm1.x 6
tm12=formatf tm1.y 6
tm13=formatf tm1.z 6
tm21=formatf tm2.x 6
tm22=formatf tm2.y 6
tm23=formatf tm2.z 6
tm31=formatf tm3.x 6
tm32=formatf tm3.y 6
tm33=formatf tm3.z 6
tm41=formatf tm4.x 6
tm42=formatf tm4.y 6
tm43=formatf tm4.z 6
format " dc.s %,%,%\n" tm11 tm12 tm13 to:out_file
format " dc.s %,%,%\n" tm21 tm22 tm23 to:out_file
format " dc.s %,%,%\n" tm31 tm32 tm33 to:out_file
format " dc.s %,%,%\n" tm41 tm42 tm43 to:out_file
format "\n" to:out_file
)
)
close out_file
shelllaunch "notepad.exe" filename
)
-- theend
void DS3231::setDateTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
{
Wire.beginTransmission(DS3231_ADDRESS);
#if ARDUINO >= 100
Wire.write(DS3231_REG_TIME);
#else
Wire.send(DS3231_REG_TIME);
#endif
#if ARDUINO >= 100
Wire.write(dec2bcd(second));
Wire.write(dec2bcd(minute));
Wire.write(dec2bcd(hour));
Wire.write(dec2bcd(dow(year, month, day)));
Wire.write(dec2bcd(day));
Wire.write(dec2bcd(month));
Wire.write(dec2bcd(year-2000));
#else
Wire.send(dec2bcd(second));
Wire.send(dec2bcd(minute));
Wire.send(dec2bcd(hour));
Wire.send(dec2bcd(dow(year, month, day)));
Wire.send(dec2bcd(day));
Wire.send(dec2bcd(month));
Wire.send(dec2bcd(year-2000));
#endif
#if ARDUINO >= 100
Wire.write(DS3231_REG_TIME);
#else
Wire.send(DS3231_REG_TIME);
#endif
Wire.endTransmission();
}
void DS3231::setDateTime(uint32_t t)
{
t -= 946681200;
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
second = t % 60;
t /= 60;
minute = t % 60;
t /= 60;
hour = t % 24;
uint16_t days = t / 24;
uint8_t leap;
for (year = 0; ; ++year)
{
leap = year % 4 == 0;
if (days < 365 + leap)
{
break;
}
days -= 365 + leap;
}
for (month = 1; ; ++month)
{
uint8_t daysPerMonth = pgm_read_byte(daysArray + month - 1);
if (leap && month == 2)
{
++daysPerMonth;
}
if (days < daysPerMonth)
{
break;
}
days -= daysPerMonth;
}
day = days + 1;
setDateTime(year+2000, month, day, hour, minute, second);
}
void DS3231::setDateTime(const char* date, const char* time)
{
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
year = conv2d(date + 9);
switch (date[0])
{
case 'J': month = date[1] == 'a' ? 1 : month = date[2] == 'n' ? 6 : 7; break;
case 'F': month = 2; break;
case 'A': month = date[2] == 'r' ? 4 : 8; break;
case 'M': month = date[2] == 'r' ? 3 : 5; break;
case 'S': month = 9; break;
case 'O': month = 10; break;
case 'N': month = 11; break;
case 'D': month = 12; break;
}
day = conv2d(date + 4);
hour = conv2d(time);
minute = conv2d(time + 3);
second = conv2d(time + 6);
setDateTime(year+2000, month, day, hour, minute, second);
}
char* DS3231::dateFormat(const char* dateFormat, RTCDateTime dt)
{
char buffer[255];
buffer[0] = 0;
char helper[11];
while (*dateFormat != '\0')
{
switch (dateFormat[0])
{
// Day decoder
case 'd':
sprintf(helper, "%02d", dt.day);
strcat(buffer, (const char *)helper);
break;
case 'j':
sprintf(helper, "%d", dt.day);
strcat(buffer, (const char *)helper);
break;
case 'l':
strcat(buffer, (const char *)strDayOfWeek(dt.dayOfWeek));
break;
case 'D':
strncat(buffer, strDayOfWeek(dt.dayOfWeek), 3);
break;
case 'N':
sprintf(helper, "%d", dt.dayOfWeek);
strcat(buffer, (const char *)helper);
break;
case 'w':
sprintf(helper, "%d", (dt.dayOfWeek + 7) % 7);
strcat(buffer, (const char *)helper);
break;
case 'z':
sprintf(helper, "%d", dayInYear(dt.year, dt.month, dt.day)+1);
strcat(buffer, (const char *)helper);
break;
case 'S':
strcat(buffer, (const char *)strDaySufix(dt.day));
break;
// Month decoder
case 'm':
sprintf(helper, "%02d", dt.month);
strcat(buffer, (const char *)helper);
break;
case 'n':
sprintf(helper, "%d", dt.month);
strcat(buffer, (const char *)helper);
break;
case 'F':
strcat(buffer, (const char *)strMonth(dt.month));
break;
case 'M':
strncat(buffer, (const char *)strMonth(dt.month), 3);
break;
case 't':
sprintf(helper, "%d", daysInMonth(dt.year, dt.month));
strcat(buffer, (const char *)helper);
break;
// Year decoder
case 'Y':
sprintf(helper, "%d", dt.year);
strcat(buffer, (const char *)helper);
break;
case 'y': sprintf(helper, "%02d", dt.year-2000);
strcat(buffer, (const char *)helper);
break;
case 'L':
sprintf(helper, "%d", isLeapYear(dt.year));
strcat(buffer, (const char *)helper);
break;
// Hour decoder
case 'H':
sprintf(helper, "%02d", dt.hour);
strcat(buffer, (const char *)helper);
break;
case 'G':
sprintf(helper, "%d", dt.hour);
strcat(buffer, (const char *)helper);
break;
case 'h':
sprintf(helper, "%02d", hour12(dt.hour));
strcat(buffer, (const char *)helper);
break;
case 'g':
sprintf(helper, "%d", hour12(dt.hour));
strcat(buffer, (const char *)helper);
break;
case 'A':
strcat(buffer, (const char *)strAmPm(dt.hour, true));
break;
case 'a':
strcat(buffer, (const char *)strAmPm(dt.hour, false));
break;
// Minute decoder
case 'i':
sprintf(helper, "%02d", dt.minute);
strcat(buffer, (const char *)helper);
break;
// Second decoder
case 's':
sprintf(helper, "%02d", dt.second);
strcat(buffer, (const char *)helper);
break;
// Misc decoder
case 'U':
sprintf(helper, "%lu", dt.unixtime);
strcat(buffer, (const char *)helper);
break;
default:
strncat(buffer, dateFormat, 1);
break;
}
dateFormat++;
}
return buffer;
}
char* DS3231::dateFormat(const char* dateFormat, RTCAlarmTime dt)
{
char buffer[255];
buffer[0] = 0;
char helper[11];
while (*dateFormat != '\0')
{
switch (dateFormat[0])
{
// Day decoder
case 'd':
sprintf(helper, "%02d", dt.day);
strcat(buffer, (const char *)helper);
break;
case 'j':
sprintf(helper, "%d", dt.day);
strcat(buffer, (const char *)helper);
break;
case 'l':
strcat(buffer, (const char *)strDayOfWeek(dt.day));
break;
case 'D':
strncat(buffer, strDayOfWeek(dt.day), 3);
break;
case 'N':
sprintf(helper, "%d", dt.day);
strcat(buffer, (const char *)helper);
break;
case 'w':
sprintf(helper, "%d", (dt.day + 7) % 7);
strcat(buffer, (const char *)helper);
break;
case 'S':
strcat(buffer, (const char *)strDaySufix(dt.day));
break;
// Hour decoder
case 'H':
sprintf(helper, "%02d", dt.hour);
strcat(buffer, (const char *)helper);
break;
case 'G':
sprintf(helper, "%d", dt.hour);
strcat(buffer, (const char *)helper);
break;
case 'h':
sprintf(helper, "%02d", hour12(dt.hour));
strcat(buffer, (const char *)helper);
break;
case 'g':
sprintf(helper, "%d", hour12(dt.hour));
strcat(buffer, (const char *)helper);
break;
case 'A':
strcat(buffer, (const char *)strAmPm(dt.hour, true));
break;
case 'a':
strcat(buffer, (const char *)strAmPm(dt.hour, false));
break;
// Minute decoder
case 'i':
sprintf(helper, "%02d", dt.minute);
strcat(buffer, (const char *)helper);
break;
// Second decoder
case 's':
sprintf(helper, "%02d", dt.second);
strcat(buffer, (const char *)helper);
break;
default:
strncat(buffer, dateFormat, 1);
break;
}
dateFormat++;
}
return buffer;
}
RTCDateTime DS3231::getDateTime(void)
{
int values[7];
Wire.beginTransmission(DS3231_ADDRESS);
#if ARDUINO >= 100
Wire.write(DS3231_REG_TIME);
#else
Wire.send(DS3231_REG_TIME);
#endif
Wire.endTransmission();
Wire.requestFrom(DS3231_ADDRESS, 7);
while(!Wire.available()) {};
for (int i = 6; i >= 0; i--)
{
#if ARDUINO >= 100
values[i] = bcd2dec(Wire.read());
#else
values[i] = bcd2dec(Wire.receive());
#endif
}
Wire.endTransmission();
t.year = values[0] + 2000;
t.month = values[1];
t.day = values[2];
t.dayOfWeek = values[3];
t.hour = values[4];
t.minute = values[5];
t.second = values[6];
t.unixtime = unixtime();
return t;
}
uint8_t DS3231::isReady(void)
{
return true;
}
void DS3231::enableOutput(bool enabled)
{
uint8_t value;
value = readRegister8(DS3231_REG_CONTROL);
value &= 0b11111011;
value |= (!enabled << 2);
writeRegister8(DS3231_REG_CONTROL, value);
}
void DS3231::setBattery(bool timeBattery, bool squareBattery)
{
uint8_t value;
value = readRegister8(DS3231_REG_CONTROL);
if (squareBattery)
{
value |= 0b01000000;
} else
{
value &= 0b10111111;
}
if (timeBattery)
{
value &= 0b01111011;
} else
{
value |= 0b10000000;
}
writeRegister8(DS3231_REG_CONTROL, value);
}
bool DS3231::isOutput(void)
{
uint8_t value;
value = readRegister8(DS3231_REG_CONTROL);
value &= 0b00000100;
value >>= 2;
return !value;
}
void DS3231::setOutput(DS3231_sqw_t mode)
{
uint8_t value;
value = readRegister8(DS3231_REG_CONTROL);
value &= 0b11100111;
value |= (mode << 3);
writeRegister8(DS3231_REG_CONTROL, value);
}
DS3231_sqw_t DS3231::getOutput(void)
{
uint8_t value;
value = readRegister8(DS3231_REG_CONTROL);
value &= 0b00011000;
value >>= 3;
return (DS3231_sqw_t)value;
}
void DS3231::enable32kHz(bool enabled)
{
uint8_t value;
value = readRegister8(DS3231_REG_STATUS);
value &= 0b11110111;
value |= (enabled << 3);
writeRegister8(DS3231_REG_STATUS, value);
}
bool DS3231::is32kHz(void)
{
uint8_t value;
value = readRegister8(DS3231_REG_STATUS);
value &= 0b00001000;
value >>= 3;
return value;
}
#ifndef DS3231_h
#define DS3231_h
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define DS3231_ADDRESS (0x68)
#define DS3231_REG_TIME (0x00)
#define DS3231_REG_ALARM_1 (0x07)
#define DS3231_REG_ALARM_2 (0x0B)
#define DS3231_REG_CONTROL (0x0E)
#define DS3231_REG_STATUS (0x0F)
#define DS3231_REG_TEMPERATURE (0x11)
#ifndef RTCDATETIME_STRUCT_H
#define RTCDATETIME_STRUCT_H
struct RTCDateTime
{
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t dayOfWeek;
uint32_t unixtime;
};
struct RTCAlarmTime
{
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
};
#endif
typedef enum
{
DS3231_1HZ = 0x00,
DS3231_4096HZ = 0x01,
DS3231_8192HZ = 0x02,
DS3231_32768HZ = 0x03
} DS3231_sqw_t;
typedef enum
{
DS3231_EVERY_SECOND = 0b00001111,
DS3231_MATCH_S = 0b00001110,
DS3231_MATCH_M_S = 0b00001100,
DS3231_MATCH_H_M_S = 0b00001000,
DS3231_MATCH_DT_H_M_S = 0b00000000,
DS3231_MATCH_DY_H_M_S = 0b00010000
} DS3231_alarm1_t;
typedef enum
{
DS3231_EVERY_MINUTE = 0b00001110,
DS3231_MATCH_M = 0b00001100,
DS3231_MATCH_H_M = 0b00001000,
DS3231_MATCH_DT_H_M = 0b00000000,
DS3231_MATCH_DY_H_M = 0b00010000
} DS3231_alarm2_t;
class DS3231
{
public:
bool begin(void);
void setDateTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second);
void setDateTime(uint32_t t);
void setDateTime(const char* date, const char* time);
RTCDateTime getDateTime(void);
uint8_t isReady(void);
DS3231_sqw_t getOutput(void);
void setOutput(DS3231_sqw_t mode);
void enableOutput(bool enabled);
bool isOutput(void);
void enable32kHz(bool enabled);
bool is32kHz(void);
void forceConversion(void);
float readTemperature(void);
void setAlarm1(uint8_t dydw, uint8_t hour, uint8_t minute, uint8_t second, DS3231_alarm1_t mode, bool armed = true);
RTCAlarmTime getAlarm1(void);
DS3231_alarm1_t getAlarmType1(void);
bool isAlarm1(bool clear = true);
void armAlarm1(bool armed);
bool isArmed1(void);
void clearAlarm1(void);
void setAlarm2(uint8_t dydw, uint8_t hour, uint8_t minute, DS3231_alarm2_t mode, bool armed = true);
RTCAlarmTime getAlarm2(void);
DS3231_alarm2_t getAlarmType2(void);
bool isAlarm2(bool clear = true);
void armAlarm2(bool armed);
bool isArmed2(void);
void clearAlarm2(void);
void setBattery(bool timeBattery, bool squareBattery);
char* dateFormat(const char* dateFormat, RTCDateTime dt);
char* dateFormat(const char* dateFormat, RTCAlarmTime dt);
private:
RTCDateTime t;
char *strDayOfWeek(uint8_t dayOfWeek);
char *strMonth(uint8_t month);
char *strAmPm(uint8_t hour, bool uppercase);
char *strDaySufix(uint8_t day);
uint8_t hour12(uint8_t hour24);
uint8_t bcd2dec(uint8_t bcd);
uint8_t dec2bcd(uint8_t dec);
long time2long(uint16_t days, uint8_t hours, uint8_t minutes, uint8_t seconds);
uint16_t date2days(uint16_t year, uint8_t month, uint8_t day);
uint8_t daysInMonth(uint16_t year, uint8_t month);
uint16_t dayInYear(uint16_t year, uint8_t month, uint8_t day);
bool isLeapYear(uint16_t year);
uint8_t dow(uint16_t y, uint8_t m, uint8_t d);
uint32_t unixtime(void);
uint8_t conv2d(const char* p);
void writeRegister8(uint8_t reg, uint8_t value);
uint8_t readRegister8(uint8_t reg);
};
#endif
#include
#include
#include
#include
#include
#include
#include
#define cudaCheck(err) (cudaCheck(err, __FILE__, __LINE__))
const std::string errLogFile = "matrixValidationFailure.txt";
int main(int argc, char **argv) {
if (argc != 2) {
std::cerr << "Please select a kernel (range 0 - 12, 0 for NVIDIA cuBLAS)"
<< std::endl;
exit(EXIT_FAILURE);
}
// get kernel number
int kernel_num = std::stoi(argv[1]);
if (kernel_num < 0 || kernel_num > 12) {
std::cerr << "Please enter a valid kernel number (0-12)" << std::endl;
exit(EXIT_FAILURE);
}
// get environment variable for device
int deviceIdx = 0;
if (getenv("DEVICE") != NULL) {
deviceIdx = atoi(getenv("DEVICE"));
}
cudaCheck(cudaSetDevice(deviceIdx));
printf("Running kernel %d on device %d.\n", kernel_num, deviceIdx);
// print some device info
// CudaDeviceInfo();
// Declare the handle, create the handle, cublasCreate will return a value of
// type cublasStatus_t to determine whether the handle was created
// successfully (the value is 0)
cublasHandle_t handle;
if (cublasCreate(&handle)) {
std::cerr << "Create cublas handle error." << std::endl;
exit(EXIT_FAILURE);
};
// Using cudaEvent for gpu stream timing, cudaEvent is equivalent to
// publishing event tasks in the target stream
float elapsed_time;
cudaEvent_t beg, end;
cudaEventCreate(&beg);
cudaEventCreate(&end);
// cuBLAS FLOPs ceiling is reached at 8192
std::vector SIZE = {128, 256, 512, 1024, 2048, 4096};
long m, n, k, max_size;
max_size = SIZE[SIZE.size() - 1];
std::cout << "Max size: " << max_size << std::endl;
float alpha = 0.5, beta = 3.0; // GEMM input parameters, C=α*AB+β*C
float *A = nullptr, *B = nullptr, *C = nullptr,
*C_ref = nullptr; // host matrices
float *dA = nullptr, *dB = nullptr, *dC = nullptr,
*dC_ref = nullptr; // device matrices
A = (float *)malloc(sizeof(float) * max_size * max_size);
B = (float *)malloc(sizeof(float) * max_size * max_size);
C = (float *)malloc(sizeof(float) * max_size * max_size);
C_ref = (float *)malloc(sizeof(float) * max_size * max_size);
randomize_matrix(A, max_size * max_size);
randomize_matrix(B, max_size * max_size);
randomize_matrix(C, max_size * max_size);
cudaCheck(cudaMalloc((void **)&dA, sizeof(float) * max_size * max_size));
cudaCheck(cudaMalloc((void **)&dB, sizeof(float) * max_size * max_size));
cudaCheck(cudaMalloc((void **)&dC, sizeof(float) * max_size * max_size));
cudaCheck(cudaMalloc((void **)&dC_ref, sizeof(float) * max_size * max_size));
cudaCheck(cudaMemcpy(dA, A, sizeof(float) * max_size * max_size,
cudaMemcpyHostToDevice));
cudaCheck(cudaMemcpy(dB, B, sizeof(float) * max_size * max_size,
cudaMemcpyHostToDevice));
cudaCheck(cudaMemcpy(dC, C, sizeof(float) * max_size * max_size,
cudaMemcpyHostToDevice));
cudaCheck(cudaMemcpy(dC_ref, C, sizeof(float) * max_size * max_size,
cudaMemcpyHostToDevice));
int repeat_times = 50;
for (int size : SIZE) {
m = 32;
n = k = size;
std::cout << "dimensions(m,n,k) " << m << "," << n << "," << k << ", alpha: " << alpha
<< ", beta: " << beta << std::endl;
// Verify the correctness of the calculation, and execute it once before the
// kernel function timing to avoid cold start errors
if (kernel_num != 0) {
run_kernel(0, m, n, k, alpha, dA, dB, beta, dC_ref,
handle); // cuBLAS
run_kernel(kernel_num, m, n, k, alpha, dA, dB, beta, dC,
handle); // Executes the kernel, modifies the result matrix
cudaCheck(cudaDeviceSynchronize());
cudaCheck(cudaGetLastError()); // Check for async errors during kernel run
cudaMemcpy(C, dC, sizeof(float) * m * n, cudaMemcpyDeviceToHost);
cudaMemcpy(C_ref, dC_ref, sizeof(float) * m * n, cudaMemcpyDeviceToHost);
if (!verify_matrix(C_ref, C, m * n)) {
std::cout
<< "Failed to pass the correctness verification against NVIDIA "
"cuBLAS."
<< std::endl;
if (m <= 128) {
std::cout << " Logging faulty output into " << errLogFile << "\n";
std::ofstream fs;
fs.open(errLogFile);
fs << "A:\n";
print_matrix(A, m, n, fs);
fs << "B:\n";
print_matrix(B, m, n, fs);
fs << "C:\n";
print_matrix(C, m, n, fs);
fs << "Should:\n";
print_matrix(C_ref, m, n, fs);
}
exit(EXIT_FAILURE);
}
}
cudaEventRecord(beg);
for (int j = 0; j < repeat_times; j++) {
// We don't reset dC between runs to save time
run_kernel(kernel_num, m, n, k, alpha, dA, dB, beta, dC, handle);
}
cudaEventRecord(end);
cudaEventSynchronize(beg);
cudaEventSynchronize(end);
cudaEventElapsedTime(&elapsed_time, beg, end);
elapsed_time /= 1000.; // Convert to seconds
long flops = 2 * m * n * k;
printf(
"Average elapsed time: (%7.6f) s, performance: (%7.1f) GFLOPS. size: "
"(%ld).\n",
elapsed_time / repeat_times,
(repeat_times * flops * 1e-9) / elapsed_time, m);
fflush(stdout);
// make dC and dC_ref equal again (we modified dC while calling our kernel
// for benchmarking)
cudaCheck(cudaMemcpy(dC, dC_ref, sizeof(float) * m * n,
cudaMemcpyDeviceToDevice));
}
// Free up CPU and GPU space
free(A);
free(B);
free(C);
free(C_ref);
cudaFree(dA);
cudaFree(dB);
cudaFree(dC);
cudaFree(dC_ref);
cublasDestroy(handle);
return 0;
};
#include
#include
#include
__global__ void kernel(uint *A, uint *B, int row) {
auto x = threadIdx.x / 4;
auto y = threadIdx.x % 4;
A[x * row + y] = x;
B[x * row + y] = y;
}
int main(int argc, char **argv) {
uint *Xs, *Ys;
uint *Xs_d, *Ys_d;
uint SIZE = 4;
Xs = (uint *)malloc(SIZE * SIZE * sizeof(uint));
Ys = (uint *)malloc(SIZE * SIZE * sizeof(uint));
cudaMalloc((void **)&Xs_d, SIZE * SIZE * sizeof(uint));
cudaMalloc((void **)&Ys_d, SIZE * SIZE * sizeof(uint));
dim3 grid_size(1, 1, 1);
dim3 block_size(4 * 4);
kernel<<>>(Xs_d, Ys_d, 4);
cudaMemcpy(Xs, Xs_d, SIZE * SIZE * sizeof(uint), cudaMemcpyDeviceToHost);
cudaMemcpy(Ys, Ys_d, SIZE * SIZE * sizeof(uint), cudaMemcpyDeviceToHost);
cudaDeviceSynchronize();
for (int row = 0; row < SIZE; ++row) {
for (int col = 0; col < SIZE; ++col) {
std::cout << "[" << Xs[row * SIZE + col] << "|" << Ys[row * SIZE + col]
<< "] ";
}
std::cout << "\n";
}
cudaFree(Xs_d);
cudaFree(Ys_d);
free(Xs);
free(Ys);
}
name: SGEMM_CUDA
channels:
- conda-forge
dependencies:
- python
- black
- cmake
- matplotlib
- seaborn
- tabulate
.PHONY: all build debug clean profile bench cuobjdump
CMAKE := cmake
BUILD_DIR := build
BENCHMARK_DIR := benchmark_results
all: build
build:
@mkdir -p $(BUILD_DIR)
@cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=Release ..
@$(MAKE) -C $(BUILD_DIR)
debug:
@mkdir -p $(BUILD_DIR)
@cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=Debug ..
@$(MAKE) -C $(BUILD_DIR)
clean:
@rm -rf $(BUILD_DIR)
FUNCTION := $$(cuobjdump -symbols build/sgemm | grep -i Warptiling | awk '{print $$NF}')
cuobjdump: build
@cuobjdump -arch sm_86 -sass -fun $(FUNCTION) build/sgemm | c++filt > build/cuobjdump.sass
@cuobjdump -arch sm_86 -ptx -fun $(FUNCTION) build/sgemm | c++filt > build/cuobjdump.ptx
# Usage: make profile KERNEL= PREFIX=
profile: build
@ncu --set full --export $(BENCHMARK_DIR)/$(PREFIX)kernel_$(KERNEL) --force-overwrite $(BUILD_DIR)/sgemm $(KERNEL)
bench: build
@bash gen_benchmark_results.sh
[-0.01, 3.00, 3.01, -2.04, -1.02, -3.02, 0.02, 0.02, 4.02, 4.03, -3.01, -3.04, 0.02, 4.01, 4.02, -4.01, -3.03, 1.01, -4.00, -1.04, -0.02, 3.03, -0.03, -1.04, 3.04, 2.03, 3.03, -1.04, -3.01, -3.04, 4.01, -2.01, 3.02, 2.03, -3.03, 1.00, 0.03, -1.01, -2.00, 4.03, -3.04, 2.02, 1.00, -3.04, 2.02, 2.03, 0.00, -4.02, -3.01, -4.02, -2.03, 1.00, 1.03, -3.01, -2.03, 0.00, 3.03, -4.02, 1.02, -1.02, 4.01, 1.02, 3.00, 1.03, 4.01, -0.03, 1.03, -2.02, -1.01, 2.02, -3.01, -0.04, 4.02, 2.04, -3.03, -2.00, 2.01, 4.04, 1.02, -0.01, 3.00, -2.02, -3.04, 1.03, -3.01, 3.03, -2.03, -4.02, 0.03, 0.00, -4.03, -4.00, -1.00, 2.02, 3.02, -4.01, -0.00, 0.01, 1.03, 4.03, 4.00, -0.04, 4.02, -2.04, 0.02, -2.03, 0.04, -2.01, 2.03, -3.02, 4.03, 3.04, 3.00, -1.03, -0.03, -4.03, -4.00, 4.02, 2.02, -4.00, -4.04, 4.04, -0.00, 1.01, -3.03, -0.03, 1.04, -2.01, -0.00, 3.04, 1.03, 2.04, 4.04, -1.02, 2.03, 0.03, 1.01, -4.04, 1.01, -1.02, -2.03, 3.00, 0.04, -0.00, -0.04, -1.04, 0.02, 3.01, -4.03, 0.01, 3.03, 0.01, 1.03, 3.00, -3.00, 1.04, 0.04, -2.04, -1.00, 0.02, 0.01, -2.01, -4.02, 4.02, -2.01, 2.04, -1.01, 2.03, 2.01, 0.02, 1.02, 4.01, 2.00, 1.02, 3.04, -1.01, -2.04, 3.02, 1.01, 0.04, 1.00, -3.04, 3.03, -2.00, 3.00, -3.01, 4.01, 3.01, 1.02, 0.02, 3.00, -1.00, 4.03, -0.02, 1.03, 1.01, 4.02, 4.02, 1.01, 0.01, 4.04, 2.02, 4.01, 4.04, -1.02, 3.03, 4.04, 3.04, -1.00, -1.02, -3.02, 2.01, -0.02, -1.01, 4.02, 0.03, 4.04, -2.03, -2.04, -2.02, -4.00, -3.03, -0.00, -0.03, 4.02, 2.04, -3.00, 2.04, -1.02, 0.01, -0.00, 3.04, -4.01, -2.01, 2.02, -4.01, 3.01, -2.03, 4.04, 3.01, -4.02, -2.00, -4.01, 3.03, -0.01, 2.02, -4.00, 3.03, 1.04, 2.02, -3.03, 2.01, 2.02, -0.02, -4.02, -2.00;
-1.04, -1.04, -2.00, -0.04, -1.00, -0.04, 0.04, -2.04, -2.04, -2.01, 2.00, 1.01, -4.03, 4.00, -0.02, -3.02, 1.04, -4.01, -1.00, -1.04, 4.03, -2.00, 3.04, -2.00, 1.00, 1.01, 1.02, -2.04, 1.00, 2.03, 0.03, 1.02, 3.00, -3.03, 0.01, -0.04, -3.03, -1.00, 3.03, -2.03, 0.03, 2.02, -4.00, -0.00, 3.00, 2.02, -3.03, -2.04, -2.04, -3.01, 1.04, -2.01, -2.01, 0.03, 1.04, 4.03, 2.01, 0.01, 4.03, 0.03, -4.04, -4.03, -4.00, -0.03, -0.01, 4.00, -2.00, 2.00, 3.01, 0.01, -4.00, -2.02, 2.01, 1.03, -4.03, -1.04, -3.02, 2.01, 3.01, 0.01, -1.01, -1.03, -3.02, -4.04, 2.03, 1.02, 1.02, -0.01, -2.02, 4.02, -4.03, -1.01, 1.00, -3.01, -4.01, 4.02, 2.03, 2.01, -0.03, -4.04, 1.00, -3.02, -2.03, 0.03, -3.03, -1.04, -3.01, -2.00, -3.02, -1.01, -2.02, 0.02, -2.01, 4.02, -2.00, -3.01, 4.04, 3.01, 1.02, -2.03, -2.02, -2.02, 2.02, 4.01, 2.00, -3.03, -1.04, -4.03, 0.01, -0.03, -3.00, 4.00, -4.02, -0.01, 4.01, -2.04, 1.03, -3.02, -4.00, -2.00, 4.04, -0.03, 3.02, -1.02, -1.03, -2.01, -0.04, -0.02, 3.02, 0.04, -0.03, 2.00, 0.04, 4.02, -4.03, -0.02, -1.00, -4.00, -2.01, -3.01, 2.01, -4.03, 4.00, 0.02, -1.01, 1.04, 3.00, -0.01, -1.04, 4.04, -3.01, 1.03, 2.02, 1.04, -2.01, -1.04, -2.02, -4.04, -0.00, -0.01, -0.00, -1.01, 0.03, 2.02, 1.04, -4.00, -0.04, 2.03, -2.03, -1.00, -1.02, -3.03, -0.01, -1.03, -2.02, 3.03, -1.03, -3.00, -2.02, 1.00, 0.02, 0.00, 2.01, 0.02, -1.01, -4.02, -1.03, 0.01, -3.00, -3.02, 3.04, -3.04, 0.04, -4.04, -4.02, 1.01, -1.00, -2.02, -3.02, -3.00, -4.01, 2.04, 3.01, 4.01, 2.00, 2.02, 1.00, -3.04, -0.04, -0.03, 2.02, 0.02, -3.00, 4.01, -2.04, 4.03, 2.04, -0.04, -3.00, 0.00, -3.00, -2.00, -3.03, 0.00, 3.04, -3.03, -1.02, -1.02, -0.00, 1.03, 0.01, 2.01, -4.01, -0.01, 4.01, 4.04;
2.02, -3.03, 2.01, -3.02, -2.03, -0.02, -1.01, 3.03, 1.04, -4.00, 2.04, -0.03, 1.00, 4.01, 2.03, -4.00, -2.04, 0.04, 2.00, -4.01, 0.04, -4.01, -1.04, 1.00, 0.02, 0.04, -3.03, -3.03, -1.02, -3.04, 0.04, 4.03, 3.01, 3.04, -0.02, -1.02, 1.02, -3.01, 3.04, 3.02, 2.04, 0.04, -2.02, -3.02, -1.03, 4.01, -1.02, 1.02, -2.00, 0.00, -2.03, -0.03, -2.00, 1.00, -1.04, -0.03, 1.02, -4.03, -1.02, -1.04, -1.03, -0.04, 3.01, 2.04, 2.02, -2.02, -3.03, 1.00, 1.01, -3.04, -3.02, 3.02, 4.02, -1.00, 0.02, 0.00, -1.00, -2.02, -3.00, 3.01, 3.04, 2.02, -4.02, -3.00, 4.02, 2.02, 2.00, -3.04, 4.04, -1.03, -0.01, 1.03, 1.00, 4.00, 2.04, 3.03, -2.01, 0.01, -2.01, 2.04, 0.01, -0.02, -4.01, 0.00, 0.03, -2.03, 1.00, 4.03, -2.02, 0.01, 0.04, -1.04, 1.00, 2.02, -4.02, -3.04, -0.00, 0.01, -3.04, 1.04, -0.01, 0.03, -0.01, 1.00, -0.00, 1.00, -3.02, -0.04, -4.02, 0.03, -3.00, -0.01, 3.01, -3.00, -3.00, 2.03, -0.01, 0.03, 0.02, -0.03, -2.03, -3.04, 4.04, -3.03, 2.03, -4.01, 2.01, 3.02, -2.04, 1.01, -4.03, 4.01, -0.02, 2.02, -4.02, 3.03, -3.00, 0.00, 0.00, -4.01, 4.02, 4.01, 3.01, 1.01, 0.00, 2.00, 0.04, -1.01, 0.01, -4.02, -0.03, -0.02, 3.00, -2.04, 2.04, -1.01, 3.01, -0.02, 2.04, -4.04, -1.04, -1.01, -0.01, 0.04, 0.03, 0.00, 0.00, 2.00, -4.04, -0.00, -0.02, 3.00, 1.00, 2.02, 1.02, -2.02, -3.00, -3.02, 2.03, 0.00, 0.00, -4.01, -4.04, 3.03, -4.00, 1.02, -4.00, -3.03, -0.00, -1.03, 4.03, -0.02, -3.03, 1.02, 1.03, -4.04, 1.04, 3.04, -4.04, -3.02, 0.04, -3.01, 0.04, 0.02, -1.04, 1.03, 1.04, 1.04, 3.03, 1.03, -4.04, 0.04, 3.04, 2.02, -2.03, 4.04, -0.00, -4.03, -3.02, -4.00, -4.02, 1.02, -1.03, 0.00, -3.02, -1.04, 3.04, 2.00, 4.04, -0.00, -4.04, 4.02, 3.03, 3.00, 1.00, 1.01;
3.02, -1.04, 2.00, 4.00, -1.01, 1.00, -0.00, 2.01, -4.04, -2.02, -0.01, -3.04, 4.03, -4.02, -1.00, -2.01, -0.01, 3.00, 3.01, -4.04, -3.01, -4.01, -1.01, -1.00, 1.02, -3.01, 2.04, -1.04, 4.03, -2.04, 3.02, 4.01, -2.02, -0.00, -0.04, 3.02, -2.01, -4.02, -2.03, 2.03, -2.03, -4.03, -4.02, 3.03, 4.00, -2.03, 4.00, 2.02, -4.04, 0.03, 1.03, -2.02, 0.03, -1.01, -1.02, 0.04, -3.00, 2.02, 0.02, 4.04, -3.02, -1.04, 0.02, -0.00, 0.01, -3.03, 4.01, 2.00, 3.00, -3.02, 0.00, -4.03, -1.04, -2.01, -0.02, -1.02, 4.01, 2.00, 4.03, 1.03, 1.04, 4.03, 4.01, 2.03, 1.04, -2.02, -2.01, 4.00, -0.02, 0.03, 2.04, -1.01, 4.00, -1.04, 2.02, -1.00, -3.02, 2.01, 2.03, -1.00, -0.04, -3.01, -3.00, 2.04, -2.03, 1.04, -0.04, 2.02, -4.04, 4.00, -1.02, -0.02, 3.00, -0.03, 2.00, 3.04, -4.04, 2.01, -0.02, 2.01, -2.03, 1.00, 3.01, 0.01, -2.00, 3.00, 1.04, 4.01, -0.02, 4.01, 3.03, 4.01, 2.04, -3.00, -2.04, -2.04, -2.01, 4.02, 3.02, 0.04, -4.04, 2.00, 1.02, -3.03, 2.00, 3.04, 4.04, 0.00, 3.03, 1.01, 4.00, -0.04, 2.03, 3.01, -2.03, 4.01, 3.01, 3.01, 0.01, 4.03, 4.04, -3.04, 4.01, -0.02, -4.04, -3.00, 1.04, -3.02, -2.00, 1.04, 2.00, -2.03, -2.03, -2.00, -2.02, -4.00, 0.01, 2.01, 0.00, -4.01, -4.03, 3.03, 3.02, -2.00, 3.04, 3.03, -1.00, -2.02, 3.02, -1.02, -3.03, 1.03, -4.03, -2.01, 0.04, -1.00, -1.01, 0.00, -4.01, -4.02, 2.03, 3.04, -0.00, -4.02, -3.04, -3.00, 1.04, -4.04, -0.03, 1.04, 0.01, 3.02, 0.04, 3.00, 2.03, -3.03, -3.04, -2.00, -3.03, 0.04, -3.01, 3.04, 0.02, 3.00, -4.03, -0.03, -4.01, 1.00, -3.03, -2.00, 3.04, -0.04, 1.01, 3.04, -0.04, -2.01, -2.00, -1.02, 3.02, -2.04, -3.04, -3.02, -1.03, -2.04, 0.04, 3.02, 1.01, 3.00, 3.03, -2.02, -3.00, 0.00, 3.02, 2.01, 1.03, 4.03;
cmake_minimum_required(VERSION 3.19)
project(NVIDIA_SGEMM_PRACTICE LANGUAGES CXX CUDA)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(CUDA REQUIRED)
# ensure cuda is available
include(CheckLanguage)
check_language(CUDA)
set(CMAKE_CXX_STANDARD 20)
set(CUDA_COMPUTE_CAPABILITY 86)
# in debug mode, add debug symbols to device code
# this disables most optimizations and kills performance
add_compile_options("$<$,$>:-G;-src-in-ptx>")
# add_compile_options("--ptxas-options=-v")
# Configure header file search paths
include_directories(${CUDA_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/src)
# Configure the source file path to be compiled
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC)
# generate executable
add_executable(sgemm sgemm.cu ${SRC})
set_target_properties(sgemm PROPERTIES CUDA_ARCHITECTURES ${CUDA_COMPUTE_CAPABILITY})
target_link_libraries(sgemm ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES})
add_executable(cuBLAS_sgemm cuBLAS_sgemm.cu )
set_target_properties(sgemm PROPERTIES CUDA_ARCHITECTURES ${CUDA_COMPUTE_CAPABILITY})
target_link_libraries(cuBLAS_sgemm ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES})
add_executable(simplest_kernel simplest_kernel.cu)
set_target_properties(sgemm PROPERTIES CUDA_ARCHITECTURES ${CUDA_COMPUTE_CAPABILITY})
target_link_libraries(simplest_kernel ${CUDA_LIBRARIES})
import gzip
import random
import tqdm
import numpy as np
import torch
from torch.optim import Adam
from torch.nn import functional as F
from torch.utils.data import DataLoader, Dataset
from simple_hierarchical_transformer import HierarchicalTransformer
# constants
NUM_BATCHES = int(1e5)
BATCH_SIZE = 2
GRADIENT_ACCUMULATE_EVERY = 8
LEARNING_RATE = 1e-4
VALIDATE_EVERY = 100
PRIME_LENGTH = 128
GENERATE_EVERY = 500
SEQ_LEN = 8192
GENERATE_LENGTH = 1024
# helpers
def cycle(loader):
while True:
for data in loader:
yield data
def decode_token(token):
return str(chr(max(32, token)))
def decode_tokens(tokens):
return "".join(list(map(decode_token, tokens)))
# instantiate transformer
model = HierarchicalTransformer(
num_tokens = 256,
dim = 1024,
depth = 8,
seq_len = SEQ_LEN,
use_flash_attn = True,
compress_factor = 32
).cuda()
# prepare enwik8 data
with gzip.open("./data/enwik8.gz") as file:
data = np.frombuffer(file.read(int(95e6)), dtype=np.uint8).copy()
np_train, np_valid = np.split(data, [int(90e6)])
data_train, data_val = torch.from_numpy(np_train), torch.from_numpy(np_valid)
class TextSamplerDataset(Dataset):
def __init__(self, data, seq_len):
super().__init__()
self.data = data
self.seq_len = seq_len
def __getitem__(self, index):
rand_start = torch.randint(0, self.data.size(0) - self.seq_len, (1,))
full_seq = self.data[rand_start : rand_start + self.seq_len + 1].long()
return full_seq.cuda()
def __len__(self):
return self.data.size(0) // self.seq_len
train_dataset = TextSamplerDataset(data_train, SEQ_LEN)
val_dataset = TextSamplerDataset(data_val, SEQ_LEN)
train_loader = cycle(DataLoader(train_dataset, batch_size=BATCH_SIZE))
val_loader = cycle(DataLoader(val_dataset, batch_size=BATCH_SIZE))
# optimizer
optim = Adam(model.parameters(), lr = LEARNING_RATE)
# training
for i in tqdm.tqdm(range(NUM_BATCHES), mininterval = 10.0, desc = "training"):
model.train()
for _ in range(GRADIENT_ACCUMULATE_EVERY):
loss, (ce_loss, recon_loss) = model(next(train_loader), return_loss = True)
loss.backward(loss / GRADIENT_ACCUMULATE_EVERY)
print(f"training loss: {ce_loss.item()}")
torch.nn.utils.clip_grad_norm_(model.parameters(), 0.5)
optim.step()
optim.zero_grad()
if i % VALIDATE_EVERY == 0:
model.eval()
with torch.no_grad():
loss, (ce_loss, recon_loss) = model(next(val_loader), return_loss = True)
print(f"validation loss: {ce_loss.item()}")
if i % GENERATE_EVERY == 0:
model.eval()
inp = random.choice(val_dataset)[:PRIME_LENGTH]
prime = decode_tokens(inp)
print(f"%s \n\n %s", (prime, "*" * 100))
sample = model.generate(inp[None, ...], GENERATE_LENGTH)
output_str = decode_tokens(sample[0])
print(output_str, "\n")
{
"version": "1.0",
"truncation": null,
"padding": null,
"added_tokens": [
{
"id": 0,
"content": "",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": true,
"special": true
},
{
"id": 1,
"content": "",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": true,
"special": true
},
{
"id": 2,
"content": "",
"single_word": false,
"lstrip": false,
"rstrip": false,
"normalized": true,
"special": true
}
],
"normalizer": {
"type": "Sequence",
"normalizers": [
{
"type": "Prepend",
"prepend": "▁"
},
{
"type": "Replace",
"pattern": {
"String": " "
},
"content": "▁"
}
]
},
"pre_tokenizer": null,
"post_processor": {
"type": "TemplateProcessing",
"single": [
{
"SpecialToken": {
"id": "",
"type_id": 0
}
},
{
"Sequence": {
"id": "A",
"type_id": 0
}
}
],
"pair": [
{
"SpecialToken": {
"id": "",
"type_id": 0
}
},
{
"Sequence": {
"id": "A",
"type_id": 0
}
},
{
"SpecialToken": {
"id": "",
"type_id": 1
}
},
{
"Sequence": {
"id": "B",
"type_id": 1
}
}
],
"special_tokens": {
"": {
"id": "",
"ids": [
1
],
"tokens": [
""
]
}
}
},
"decoder": {
"type": "Sequence",
"decoders": [
{
"type": "Replace",
"pattern": {
"String": "▁"
},
"content": " "
},
{
"type": "ByteFallback"
},
{
"type": "Fuse"
},
{
"type": "Strip",
"content": " ",
"start": 1,
"stop": 0
}
]
}
}
#include "q_gemm.cuh"
#include "util.cuh"
#include "matrix_view.cuh"
#include "../config.h"
// #include
// #include
#define BLOCK_KN_SIZE 512
#define MAX_GROUPS_IN_BLOCK (BLOCK_KN_SIZE / 32)
#define MAX_COUNT_M 2
#define CLEAR_N_SIZE 256
//#define DEBUG
#include "q_gemm_dq.cuh"
typedef void (*fp_gemm_half_q_half_kernel)
(
const half*,
const uint32_t*,
const uint32_t*,
const half*,
const uint16_t*,
half*,
const int,
const int,
const int,
const int,
const int,
const uint16_t*,
const int,
const int,
const int,
const int,
const int,
const int
);
template
__global__ void gemm_half_q_half_kernel
(
const half* a,
const uint32_t* b_q_weight,
const uint32_t* b_q_scale,
const half* b_q_scale_max,
const uint16_t* b_q_groups,
half* c,
const int size_m,
const int size_n,
const int size_k,
const int groups,
const int groupsize,
const uint16_t* __restrict__ b_q_perm,
const int rows_8,
const int rows_6,
const int rows_5,
const int rows_4,
const int rows_3,
const int rows_2
)
{
MatrixView_half a_(a, size_m, size_k);
MatrixView_half_rw c_(c, size_m, size_n);
MatrixView_q4_row b_q_scale_(b_q_scale, groups, size_n);
int t = threadIdx.x;
// Block
int offset_n = blockIdx.x * BLOCK_KN_SIZE;
int offset_m = blockIdx.y * m_count;
int offset_k = blockIdx.z * BLOCK_KN_SIZE;
int end_n = min(offset_n + BLOCK_KN_SIZE, size_n);
int end_m = min(offset_m + m_count, size_m);
int end_k = min(offset_k + BLOCK_KN_SIZE, size_k);
int n = offset_n + t;
// Preload block_a
__shared__ half block_a[m_count][BLOCK_KN_SIZE];
if (offset_k + t < end_k)
{
for (int m = 0; m < m_count; ++m)
{
const half* a_ptr = a_.item_ptr(offset_m + m, 0);
half* block_a_ptr = block_a[m];
half a0 = a_ptr[b_q_perm[offset_k + t]];
block_a_ptr[t] = a0;
}
}
__syncthreads();
if (n >= size_n) return;
// for (int xs_n = 0; xs_n < size_n - BLOCK_KN_SIZE;
// Advance to subblock
// int sub_offset_k = SUBBLOCK_K_SIZE * threadIdx.y;
// offset_k += sub_offset_k;
// end_k = min(offset_k + SUBBLOCK_K_SIZE, size_k);
// if (threadIdx.y > 0) return;
// int sub_offset_k = 0;
// Find initial group
int group = offset_k / groupsize;
// Preload scales
half scales[MAX_GROUPS_IN_BLOCK];
int groups_in_block = DIVIDE((end_k - offset_k), groupsize);
for (int g = 0; g < groups_in_block; g++)
{
half s = dq_scale(b_q_scale_.item(group + g, n), b_q_scale_max[group + g]);
scales[g] = s;
}
// Find initial q row
int pre_rows_8 = min(rows_8, offset_k);
int pre_rows_6 = offset_k > rows_8 ? min(rows_6, offset_k) - rows_8 : 0;
int pre_rows_5 = offset_k > rows_6 ? min(rows_5, offset_k) - rows_6 : 0;
int pre_rows_4 = offset_k > rows_5 ? min(rows_4, offset_k) - rows_5 : 0;
int pre_rows_3 = offset_k > rows_4 ? min(rows_3, offset_k) - rows_4 : 0;
int pre_rows_2 = offset_k > rows_3 ? min(rows_2, offset_k) - rows_3 : 0;
int qk = 0;
qk += pre_rows_8 / 32 * 8;
qk += pre_rows_6 / 32 * 6;
qk += pre_rows_5 / 32 * 5;
qk += pre_rows_4 / 32 * 4;
qk += pre_rows_3 / 32 * 3;
qk += pre_rows_2 / 32 * 2;
const uint32_t* b_ptr = b_q_weight + qk * size_n + n;
const half* a_ptr = &block_a[0][0];
int a_stride = BLOCK_KN_SIZE;
// const half* a_ptr = a_.item_ptr(offset_m, 0);
// int a_stride = size_k;
half qs_h = scales[0];
int scales_idx = 0;
int nextgroup = offset_k + groupsize;
// Column result
half2 block_c[m_count] = {};
// Dot product over groups
int k = offset_k;
while (k < rows_8 && k < end_k)
{
int end_k_sg = min(min(k + 128, rows_6), end_k);
uint32_t q_0[8], q_1[8];
load_8(b_ptr, size_n, q_0);
qdot_8bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_8bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
qdot_8bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_8bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
}
while (k < rows_6 && k < end_k)
{
int end_k_sg = min(min(k + 128, rows_5), end_k);
uint32_t q_0[6], q_1[6];
load_6(b_ptr, size_n, q_0);
qdot_6bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_6bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
qdot_6bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_6bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
}
while (k < rows_5 && k < end_k)
{
int end_k_sg = min(min(k + 128, rows_4), end_k);
uint32_t q_0[5], q_1[5];
load_5(b_ptr, size_n, q_0);
qdot_5bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_5bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
qdot_5bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_5bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
}
// while (k + 128 < rows_4 && k + 128 < end_k)
// {
// uint32_t q_0[8], q_1[8];
// load_8(b_ptr, size_n, q_0);
// load_8(b_ptr, size_n, q_1);
// qdot_4bit_64(k, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0);
// qdot_4bit_64(k, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1);
// }
while (k < rows_4 && k < end_k)
{
int end_k_sg = min(min(k + 128, rows_3), end_k);
uint32_t q_0[4], q_1[4];
load_4(b_ptr, size_n, q_0);
qdot_4bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_4bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
qdot_4bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_4bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
}
// while (k + 128 < rows_3 && k + 128 < end_k)
// {
// uint32_t q_0[6], q_1[6];
// load_6(b_ptr, size_n, q_0);
// load_6(b_ptr, size_n, q_1);
// qdot_3bit_64(k, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0);
// qdot_3bit_64(k, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1);
// }
while (k < rows_3 && k < end_k)
{
int end_k_sg = min(min(k + 128, rows_2), end_k);
uint32_t q_0[3], q_1[3];
load_3(b_ptr, size_n, q_0);
qdot_3bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_3bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
qdot_3bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_3bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
}
// while (k + 128 < rows_2 && k + 128 < end_k)
// {
// uint32_t q_0[8];
// load_8(b_ptr, size_n, q_0);
// qdot_2bit_128(k, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0);
// }
while (k < rows_2 && k < end_k)
{
int end_k_sg = min(k + 128, end_k);
uint32_t q_0[2], q_1[2];
load_2(b_ptr, size_n, q_0);
qdot_2bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_2bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
qdot_2bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_0, q_1);
qdot_2bit_32(k, end_k_sg, group, nextgroup, groupsize, n, scales, scales_idx, qs_h, block_c, a_ptr, a_stride, b_ptr, size_n, q_1, q_0);
}
// Accumulate column sums in c
for (int m = 0; m < m_count; m++) atomicAdd(c_.item_ptr(offset_m + m, n), __hadd(block_c[m].x, block_c[m].y));
//for (int m = 0; m < m_count; m++) c_.set(offset_m + m, n, block_c[m]);
}
fp_gemm_half_q_half_kernel pick_gemm_half_q_half_kernel(bool first_block, const int m_count)
{
if (m_count == 1) return gemm_half_q_half_kernel;
if (m_count == 2) return gemm_half_q_half_kernel;
// if (m_count == 3) return gemm_half_q_half_kernel;
// if (m_count == 4) return gemm_half_q_half_kernel;
// if (m_count == 5) return gemm_half_q_half_kernel;
// if (m_count == 6) return gemm_half_q_half_kernel;
// if (m_count == 7) return gemm_half_q_half_kernel;
// if (m_count == 8) return gemm_half_q_half_kernel;
return NULL;
}
void gemm_half_q_half_cuda_part
(
const half* a,
QMatrix* b,
half* c,
int size_m,
int size_n,
int size_k,
int count_m
)
{
dim3 blockDim, gridDim;
blockDim.x = BLOCK_KN_SIZE;
blockDim.y = 1;
blockDim.z = 1;
gridDim.x = DIVIDE(size_n, BLOCK_KN_SIZE);
gridDim.y = DIVIDE(size_m, count_m);
gridDim.z = DIVIDE(size_k, BLOCK_KN_SIZE);
fp_gemm_half_q_half_kernel kernel = pick_gemm_half_q_half_kernel(true, count_m);
kernel<<>>
(
a,
b->cuda_q_weight,
b->cuda_q_scale,
b->cuda_q_scale_max,
b->cuda_q_groups,
c,
size_m,
size_n,
size_k,
b->groups,
b->groupsize,
b->cuda_q_perm,
b->rows_8,
b->rows_6,
b->rows_5,
b->rows_4,
b->rows_3,
b->rows_2
);
}
void gemm_half_q_half_cuda
(
cublasHandle_t cublas_handle,
const half* a,
QMatrix* b,
half* c,
int size_m,
int size_n,
int size_k,
bool clear,
half* temp_dq
)
{
if (size_m >= MAX_Q_GEMM_ROWS)
{
// Reconstruct FP16 matrix, then cuBLAS
//DBGI3(size_m, size_n, size_k);
if (!temp_dq) temp_dq = b->temp_dq;
b->reconstruct(temp_dq);
cublasSetMathMode(cublas_handle, CUBLAS_TENSOR_OP_MATH);
//DBGI3(size_m, size_n, size_k);
const half alpha = __float2half(1.0f);
const half beta = clear ? __float2half(0.0f) : __float2half(1.0f);
cublasHgemm(cublas_handle,
CUBLAS_OP_N,
CUBLAS_OP_N,
size_n,
size_m,
size_k,
&alpha,
temp_dq,
size_n,
a,
size_k,
&beta,
c,
size_n);
// const float alpha = 1.0f;
// const float beta = clear ? 0.0f : 1.0f;
// cublasSgemmEx(cublas_handle,
// CUBLAS_OP_N,
// CUBLAS_OP_N,
// size_n,
// size_m,
// size_k,
// &alpha,
// temp_dq,
// CUDA_R_16F,
// size_n,
// a,
// CUDA_R_16F,
// size_k,
// &beta,
// c,
// CUDA_R_16F,
// size_n);
}
else
{
// Quantized matmul
if (clear) clear_tensor_cuda(c, size_m, size_n);
int max_chunks = size_m / MAX_COUNT_M;
int last_chunk = max_chunks * MAX_COUNT_M;
int last_chunk_size = size_m - last_chunk;
// DBGI3(size_m, size_n, size_k);
// DBGI3(max_chunks, last_chunk, last_chunk_size);
if (max_chunks)
gemm_half_q_half_cuda_part(a, b, c, last_chunk, size_n, size_k, MAX_COUNT_M);
if (last_chunk_size)
gemm_half_q_half_cuda_part(a + last_chunk * size_k, b, c + last_chunk * size_n, last_chunk_size, size_n, size_k, last_chunk_size);
}
}
__global__ void clear_kernel
(
half* __restrict__ c,
const int size_m,
const int size_n
)
{
int m = blockIdx.y;
int n = (blockIdx.x * CLEAR_N_SIZE + threadIdx.x) * 8;
if (n >= size_n) return;
int4* c_ptr = (int4*)(c + m * size_n + n);
*c_ptr = {};
}
void clear_tensor_cuda
(
half* c,
int size_m,
int size_n
)
{
dim3 blockDim, gridDim;
blockDim.x = CLEAR_N_SIZE;
blockDim.y = 1;
gridDim.x = DIVIDE(size_n / 8, CLEAR_N_SIZE);
gridDim.y = size_m;
clear_kernel<<>>(c, size_m, size_n);
}
#!/usr/bin/env python3
import argparse
import torch
import torch.nn as nn
from datasets import load_dataset
from gptq_triton import load_quant
from tqdm import tqdm
from transformers import AutoTokenizer, LlamaForCausalLM
parser = argparse.ArgumentParser()
parser.add_argument('--model', type=str, help='Path to model, either a HuggingFace model or a quantized model')
parser.add_argument('--quant', action='store_true', help='Whether the model is quantized')
parser.add_argument('--stride', type=int, default=512, help='Stride for calculating perplexity')
parser.add_argument('--context-length', type=int, default=2048, help='Length of context to use')
def main():
args = parser.parse_args()
if not args.quant:
model = get_llama(args.model)
model.eval()
model.to('cuda')
else:
model = load_quant(args.model)
model.eval()
model.to('cuda')
# NOTE: Setting use_fast=False for now, as the alternative was an order of magnitude slower on a recent `transformers` commit
tokenizer = AutoTokenizer.from_pretrained(args.model, use_fast=False)
context_length = model.seqlen if args.context_length is None else args.context_length
for dataset in ['wikitext-2', 'ptb', 'c4']:
ppl = calculate_perplexity(model, tokenizer, dataset, max_length=context_length, stride=args.stride)
print(f"{dataset} perplexity: {ppl}")
def get_llama(model: str):
"""
Load a pretrained Llama model
"""
def skip(*args, **kwargs):
pass
# NOTE: This is a nasty hack, but it speeds up model building by a huge amount
old_inits = (torch.nn.init.kaiming_uniform_, torch.nn.init.uniform_, torch.nn.init.normal_)
torch.nn.init.kaiming_uniform_ = skip
torch.nn.init.uniform_ = skip
torch.nn.init.normal_ = skip
model = LlamaForCausalLM.from_pretrained(model, torch_dtype='auto')
model.seqlen = 2048
# Restore the old initializers
torch.nn.init.kaiming_uniform_, torch.nn.init.uniform_, torch.nn.init.normal_ = old_inits
return model
def get_dataset(dataset_name: str, tokenizer) -> torch.Tensor:
if dataset_name == "wikitext-2":
test = load_dataset("wikitext", "wikitext-2-raw-v1", split="test")
encodings = tokenizer("\n\n".join(test["text"]), return_tensors="pt").input_ids
elif dataset_name == 'ptb':
test = load_dataset("ptb_text_only", 'penn_treebank', split="validation")
encodings = tokenizer("\n\n".join(test["sentence"]), return_tensors="pt").input_ids
elif dataset_name == 'c4':
# WARNING: Many of the files in the allenai/c4 repo are marked as "Unsafe" by HuggingFace, possibly containing a virus. This particular file is not, and I doubt it's an issue, but worth noting.
test = load_dataset('allenai/c4', 'allenai--c4', data_files={'validation': 'en/c4-validation.00000-of-00008.json.gz'}, split='validation')
encodings = [tokenizer(x, return_tensors="pt").input_ids for x in test['text'][:1000]]
encodings = torch.cat(encodings, dim=1)
else:
raise ValueError(f"Unknown dataset {dataset_name}")
return encodings
def calculate_perplexity(model, tokenizer, dataset: str, max_length: int, stride: int = 512) -> float:
print("Loading dataset...")
encodings = get_dataset(dataset, tokenizer)
seq_len = encodings.size(1)
print("Calculating perplexity...")
print(f"Sequence length: {seq_len}")
print(f"Max length: {max_length}")
print(f"Stride: {stride}")
nlls = []
prev_end_loc = 0
for begin_loc in (pbar := tqdm(range(0, seq_len - 1, stride))):
end_loc = min(seq_len - 1, begin_loc + max_length)
trg_len = end_loc - prev_end_loc # How many tokens we want to predict
input_ids = encodings[:, begin_loc:end_loc+1].to('cuda') # +1 for the labels
with torch.no_grad():
# Ask the model for logits
# NOTE: Instead of calling HF's model wrapper, we call the model directly to hopefully cut down on some memory overhead
outputs = model.model(input_ids[:, :-1], use_cache=False)
logits = model.lm_head(outputs[0][..., -trg_len:, :])
# The last trg_len tokens are the labels
labels = input_ids[:, -trg_len:].contiguous()
# Compute the NLL for this batch using flattened logits and labels
loss_fct = nn.CrossEntropyLoss()
loss = loss_fct(logits.view(-1, logits.size(-1)), labels.view(-1))
nlls.append(loss.to('cpu').to(torch.float32))
ppl = torch.exp(torch.stack(nlls).mean())
pbar.set_description(f"Perplexity: {ppl:.2f}")
prev_end_loc = end_loc
if end_loc == (seq_len - 1):
break
ppl = torch.exp(torch.stack(nlls).mean())
return ppl
if __name__ == '__main__':
main()
[metadata]
name = gptq_triton
version = 0.0.3
author = fpgaminer
author_email = fpgaminer@bitcoin-mining.com
description = Fast GPTQ kernels written in Triton
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
url = https://github.com/fpgaminer/GPTQ-triton
keywords = gptq, triton, torch, cuda, gpu, quantization, quantize, quantized, inference, deep learning, machine learning
license = Apache License 2.0
license_file = LICENSE
classifiers =
Development Status :: 3 - Alpha
License :: OSI Approved :: Apache Software License
Intended Audience :: Developers
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Scientific/Engineering :: Artificial Intelligence
Topic :: Software Development :: Libraries :: Python Modules
[options]
zip_safe = False
include_package_data = False
package_dir =
= src
packages = find:
python_requires = >=3.6
install_requires =
triton >= 2.0.0
torch >= 2.0.0
transformers
[options.packages.find]
where = src
import random
from datasets import load_dataset
def get_dataset(dataset_name: str, tokenizer, nsamples: int, seed: int, seqlen: int):
if dataset_name == "wikitext-2":
return get_wikitext2(nsamples, seed, seqlen, tokenizer)
elif dataset_name == 'ptb':
return get_ptb(nsamples, seed, seqlen, tokenizer, jointext='\n\n')
elif dataset_name == 'ptb-new':
return get_ptb(nsamples, seed, seqlen, tokenizer, jointext=' ')
elif dataset_name == 'c4':
return get_c4(nsamples, seed, seqlen, tokenizer)
else:
raise ValueError(f"Unknown dataset {dataset_name}")
def get_wikitext2(nsamples: int, seed: int, seqlen: int, tokenizer, jointext: str = '\n\n'):
traindata = load_dataset('wikitext', 'wikitext-2-raw-v1', split='train')
trainenc = tokenizer(jointext.join(traindata['text']), return_tensors='pt')
rng = random.Random(seed)
trainloader = (rng.randint(0, trainenc.input_ids.shape[1] - seqlen - 1) for _ in range(nsamples))
trainloader = [trainenc.input_ids[:, i:i+seqlen] for i in trainloader]
return trainloader
def get_ptb(nsamples: int, seed: int, seqlen: int, tokenizer, jointext: str):
traindata = load_dataset('ptb_text_only', 'penn_treebank', split='train')
trainenc = tokenizer(jointext.join(traindata['sentence']), return_tensors='pt')
rng = random.Random(seed)
trainloader = (rng.randint(0, trainenc.input_ids.shape[1] - seqlen - 1) for _ in range(nsamples))
trainloader = [trainenc.input_ids[:, i:i+seqlen] for i in trainloader]
return trainloader
def get_c4(nsamples: int, seed: int, seqlen: int, tokenizer):
# WARNING: Many of the files in the allenai/c4 repo are marked as "Unsafe" by HuggingFace, possibly containing a virus. This particular file is not, and I doubt it's an issue, but worth noting.
traindata = load_dataset('allenai/c4', 'allenai--c4', data_files={'train': 'en/c4-train.00000-of-01024.json.gz'}, split='train')
rng = random.Random(seed)
trainloader = []
for _ in range(nsamples):
while True:
i = rng.randint(0, len(traindata) - 1)
trainenc = tokenizer(traindata[i]['text'], return_tensors='pt')
if trainenc.input_ids.shape[1] >= seqlen:
break
i = rng.randint(0, trainenc.input_ids.shape[1] - seqlen - 1)
inp = trainenc.input_ids[:, i:i + seqlen]
trainloader.append(inp)
return trainloader
#!/usr/bin/env python3
"""
Benchmarks the generation speed of a model. While Benchmark.ipynb provides nice detailed performance data, it measures the kernels in isolation.
This script measures "real world" performance by running the whole model in generation mode.
It tests a grid of prompt lengths and generation lengths, and saves the timing results to `results.json`.
"""
import argparse
import itertools
import json
import os
import random
import time
import original_quant
import torch
import transformers
from gptq_triton import load_quant
from transformers import AutoTokenizer, LlamaConfig, LlamaForCausalLM
parser = argparse.ArgumentParser()
parser.add_argument('--model', type=str, help='Path to model, either a HuggingFace model or a quantized model')
parser.add_argument('--quant', action='store_true', help='Whether the model is quantized')
parser.add_argument('--cuda', type=str, help='Whether to use the old CUDA kernel and format; this must be set to the path to the CUDA quantized model, and --model must be set to a HF model')
parser.add_argument('--average', type=int, default=10, help='Number of times to run each test to get an average')
def main():
args = parser.parse_args()
if args.cuda:
model = load_cuda_quant(args.model, args.cuda, 4, -1)
model.eval()
model.to('cuda')
elif not args.quant:
model = get_llama(args.model)
model.eval()
model.to('cuda')
else:
model = load_quant(args.model)
model.eval()
model.to('cuda')
tokenizer = AutoTokenizer.from_pretrained(args.model, use_fast=False)
prompt_lengths = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
max_lengths = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
lengths = set(itertools.product(prompt_lengths, max_lengths))
# Remove lengths that we've already tested
if os.path.exists('results.jsonl'):
with open('results.jsonl', 'r') as f:
for line in f:
line = json.loads(line)
key = (line['prompt_length'], line['max_length'])
if key in lengths:
lengths.remove(key)
# Shuffle the lengths so that we don't always test in the same order and get caching effects
lengths = list(lengths)
random.shuffle(lengths)
# TODO: For some reason the first run is always slow, so we run it once before the benchmark to warm things up
encoded_prompt = tokenizer.encode("TODO", add_special_tokens=False, return_tensors='pt').to('cuda')
_ = model.generate(
input_ids=encoded_prompt,
max_length=8,
do_sample=True,
num_return_sequences=1,
suppress_tokens=[model.generation_config.eos_token_id],
)
# Run the remaining benchmarks
with open('results.jsonl', 'a') as f:
for prompt_length, max_length in lengths:
print(f'Prompt length: {prompt_length}, max length: {max_length}')
results = []
for _ in range(args.average):
# Generate a long random string
# We do this every time to avoid caching effects
prompt = ''.join(random.choice('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .,;:!?') for _ in range(2048 * 10))
# Encode and crop down
encoded_prompt = tokenizer.encode(prompt, add_special_tokens=False, return_tensors='pt')
encoded_prompt = encoded_prompt[:, :prompt_length]
encoded_prompt = encoded_prompt.to('cuda')
start_time = time.time()
_ = model.generate(
input_ids=encoded_prompt,
max_length=max_length + prompt_length,
do_sample=True,
num_return_sequences=1,
suppress_tokens=[model.generation_config.eos_token_id], # This prevents the sampler from ending early; it must generate max_length tokens
)
end_time = time.time()
gen_time = end_time - start_time
speed = max_length / gen_time
results.append((gen_time, speed))
# Compute the average
avg_time = sum(t for t, _ in results) / len(results)
avg_speed = (max_length * len(results)) / sum(t for t, _ in results)
print(f'Average generation time: {avg_time:.2f} seconds')
print(f'Average generation speed: {avg_speed:.2f} tokens per second')
print()
f.write(json.dumps({
'prompt_length': prompt_length,
'max_length': max_length,
'average_time': avg_time,
'average_speed': avg_speed,
'runs': results,
}))
f.write("\n")
f.flush()
def get_llama(model: str):
"""
Load a pretrained Llama model
"""
def skip(*args, **kwargs):
pass
# NOTE: This is a nasty hack, but it speeds up model building by a huge amount
old_inits = (torch.nn.init.kaiming_uniform_, torch.nn.init.uniform_, torch.nn.init.normal_)
torch.nn.init.kaiming_uniform_ = skip
torch.nn.init.uniform_ = skip
torch.nn.init.normal_ = skip
model = LlamaForCausalLM.from_pretrained(model, torch_dtype='auto')
model.seqlen = 2048
# Restore the old initializers
torch.nn.init.kaiming_uniform_, torch.nn.init.uniform_, torch.nn.init.normal_ = old_inits
return model
def load_cuda_quant(model, checkpoint, wbits, groupsize):
"""
Load a quantized model using the old CUDA kernel
"""
config = LlamaConfig.from_pretrained(model)
def noop(*args, **kwargs):
pass
original_inits = (torch.nn.init.kaiming_uniform_, torch.nn.init.uniform_, torch.nn.init.normal_)
torch.nn.init.kaiming_uniform_ = noop
torch.nn.init.uniform_ = noop
torch.nn.init.normal_ = noop
torch.set_default_dtype(torch.half)
original_init_weights = transformers.modeling_utils._init_weights
transformers.modeling_utils._init_weights = False
torch.set_default_dtype(torch.half)
model = LlamaForCausalLM(config)
torch.set_default_dtype(torch.float)
transformers.modeling_utils._init_weights = original_init_weights
torch.nn.init.kaiming_uniform_, torch.nn.init.uniform_, torch.nn.init.normal_ = original_inits
model = model.eval()
layers = original_quant.find_layers(model)
for name in ['lm_head']:
if name in layers:
del layers[name]
original_quant.make_quant(model, layers, wbits, groupsize, faster=False)
del layers
print('Loading model ...')
if checkpoint.endswith('.safetensors'):
from safetensors.torch import load_file as safe_load
model.load_state_dict(safe_load(checkpoint))
else:
model.load_state_dict(torch.load(checkpoint))
model.seqlen = 2048
print('Done.')
return model
if __name__ == '__main__':
main()
VPS
Oct 12, 2023
Ignas R.
10min Read
25 Common Linux Bash Script Examples to Get You Started
Bash or Bourne-again shell is one of the most popular shells and command languages for Linux VPS enthusiasts. It was first released in 1989 and was used as the default shell for most Linux distributions ever since.
Bash scripting allows users and system administrators to automate processes and save hundreds of hours of manual work. It’s worth mentioning that Bash is also available for Windows and macOS.
This tutorial will introduce you to what bash scripting is. It features over twenty useful bash script examples to start your bash scripting journey.
What Is Bash Scripting Used For
25 Bash Scripts Examples
1. Hello World
2. Echo Command
3. Sleep Command
4. Wait Command
5. Comments
6. Get User Input
7. Loops
8. Create an Array
9. Conditional Statements
10. Functions
11. Display String Length
12. Extract String
13. Find and Replace String
14. Concatenate Strings
15. Check if a Number is Even or Odd
16. Generate Factorial of Number
17. Create Directories
18. Read Files
19. Print Files With Line Count
20. Delete Files
21. Test if File Exists
22. Check Inodes and Disk Usage
23. Send Email Example
24. Update Packages
25. Show Server Information
What Is Bash Scripting Used For
Before we move on to the topic of bash scripting use cases, we need to elaborate on what bash and bash scripting are.
Bash is a command-line interface interpreter that runs in a text window where users can manage and execute shell commands. Bash – or shell scripting – on the other hand is the process of writing a set of commands to be executed on a Linux system. A file that includes such instructions is called a bash script.
To put it simply, the bash interpreter reads the bash script and executes the commands at the same time. For example, a Linux user can execute hundreds of commands with a single click instead of inputting them one by one. For this reason, bash scripting is the go-to choice for increasing productivity, setting up automation, and eliminating repetitive tasks.
25 Bash Scripts Examples
The following section will cover 25 of the most popular bash scripting examples, including variable manipulation and echoing out various values. We will also cover functions, arrays, loops, and much more.
1. Hello World
Hello World is the most simple bash script to start with. We will create a new variable called learningbash and print out the words Hello World. First, open a new shell script file with a text editor of your choice:
nano hello.sh
Paste the following lines into it:
#!/bin/bash
#Creates a new variable with a value of "Hello World"
learningbash="Hello World"
echo $learningbash
The command-line window showcasing the output of the first bash script – Hello World
The first line (/bin/bash) is used in every bash script. It instructs the operating system to use a bash interpreter as a command interpreter.
2. Echo Command
The echo bash command can be used to print out text as well as values of variables. In the following example, we will showcase how quotation marks affect the echo command. We will start by opening a new bash script file:
nano echo.sh
This simple bash script example will create a new variable and print it out while using different quotation marks.
#!/bin/bash
provider="Hostinger"
echo 'The best hosting provider is $provider'
echo "The best hosting provider is $provider"
The command-line window shows the echo command
As you can see, if the echo bash command is used with double quotation marks ““, then the script will print out the actual value of a variable. Otherwise, if the single quotation marks ‘‘ are used, it will print out only the name of a variable.
3. Sleep Command
Sleep command halts all currently running bash scripts and puts the system to sleep. Start by creating a new bash script file:
nano sleep.sh
Then, paste in the following simple script:
#!/bin/bash
sleep 10 && echo “I’ve been sleeping for 10 seconds, I want more” && sleep 10 && echo “I’m done sleeping, thanks!”
A bash script with the sleep command. The basic idea is that it puts the system to a halt for a set amount of time
The above example starts with a simple sleep bash command that will put your system to sleep for 10 seconds. After that, we combine the previously learned echo command with sleep – this way system will sleep for 10 seconds, then print out some words, sleep again, print out some words again and end its operation.
Pro Tip
A bash script can always be terminated by clicking CTRL + C without waiting for it to finish its operation.
4. Wait Command
wait is a built-in Linux command that waits for completion of running process. The wait command is used with a particular process id or job id.
Here’s how to create a wait bash script. Begin by creating a new bash file:
nano wait.sh
Paste in the following:
#!/bin/bash
wait 1234
echo “Done”
Important! If no job ID is provided, the wait command waits until all child background jobs are completed.
5. Comments
Users can easily add comments to their bash scripts with the # symbol. It is extra useful if you’ve got a lengthy script that needs explaining on some lines.
Begin by creating a new bash script:
nano comments.sh
Then paste in the following:
#!/bin/bash
# Define a variable named Hostinger
provider="Hostinger"
# Print out the following text
echo 'The best hosting provider is $provider'
# Print out the following text with $provider variable value
echo "The best hosting provider is $provider"
The command-line window showing single line comment functionality. It's worth noting that bash comments are not displayed with the script output.
Keep in mind that bash comments are only visible on a text editor.
6. Get User Input
To take input from users, we’ll use the read bash command. First, create a new bash shell file:
nano read.sh
Then, fill it with the script below:
#!/bin/bash
echo "What is your age?"
read age
echo "Wow, you look younger than $age years old"
In the above example, an age value was entered by the user. The output was then printed via the echo command.
7. Loops
A loop is an essential tool in various programming languages. To put it simply, a bash loop is a set of instructions that are repeated until a user-specified condition is reached. Start by creating a loop bash program:
nano whileloop.sh
Then paste in the following:
#!/bin/bash
n=0
while :
do
echo Countdown: $n
((n++))
done
This will work as a countdown to infinity until you press CTRL + C to stop the script.
Now that we’ve tested the while loop, we can move on to the for loop. Create a bash file for it:
nano forloop.sh
It should contain the script below:
#!/bin/bash
for (( n=2; n<=10; n++ ))
do
echo "$n seconds"
done
A bash script showcasing the "for" loop
The script prints out numbers from 2 to 10 while adding the seconds keyword to it.
8. Create an Array
A bash array is a data structure designed to store information in an indexed way. It is extra useful if users need to store and retrieve thousands of pieces of data fast. What makes bash arrays special is that unlike any other programming language, they can store different types of elements. For example, you can use a bash array to store both strings and numbers.
Create a new file in the current directory:
nano array.sh
Combine the freshly learned for loop with a new indexed array:
#!/bin/bash
# Create an indexed array
IndexedArray=(egg burger milk)
#Iterate over the array to get all the values
for i in "${IndexedArray[@]}";do echo "$i";done
A bash script to create and print out an array
The script iterates over the IndexedArray and prints out all the values.
9. Conditional Statements
The most popular and widely used conditional statement is if. Even though the if statement is easy to write and understand, it can be used in advanced shell scripts as well.
Begin with a new bash file:
nano if.sh
Paste the code below in it:
#!/bin/bash
salary=1000
expenses=800
#Check if salary and expenses are equal
if [ $salary == $expenses ];
then
echo "Salary and expenses are equal"
#Check if salary and expenses are not equal
elif [ $salary != $expenses ];
then
echo "Salary and expenses are not equal"
fi
This script creates two new variables and compares whether they are equal or not.
10. Functions
A bash function is a set of commands that can be reused numerous times throughout a bash script. Create a new file:
nano function.sh
Then, paste in the following code – it creates a simple Hello World function.
#!/bin/bash
hello () {
echo 'Hello World!'
}
hello
11. Display String Length
There are a couple of ways of counting string length in bash. We’ll talk about the simplest. Create a file named stringlength.sh:
nano stringlength.sh
Fill it with the following:
#!/bin/bash
# Create a new string
mystring="lets count the length of this string"
i=${#mystring}
echo "Length: $i"
Here, the # operator is used to get the length of the string variable.
12. Extract String
If users need to remove unnecessary parts from strings, they can use the Bash string extraction tools. Start by creating a new bash script:
nano extractstring.sh
The following script has 4 values, 3 of them being strings. In our example, we will extract only the number value. This can be done via the cut command. First, we instruct the command that each variable is separated by a comma by using the -d flag. Then we ask the cut command to extract the 5th value.
#!/bin/bash
cut -d , -f 5 <<< "Website,Domain,DNS,SMTP,5005"
In another example, we have a string that is mixed with some numbers. We will use expr substr commands to extract only the Hostinger text value.
#!/bin/bash
expr substr "458449Hostinger4132" 7 9
13. Find and Replace String
Another useful bash script for strings is find and replace. Create a file named findreplace.sh:
nano findreplace.sh
Then paste in the following bash script:
#!/bin/bash
first="I drive a BMW and Volvo"
second="Audi"
echo "${first/BMW/"$second"}"
Find and replace script in bash
The find and replace functionality doesn’t require any special commands, it can all be done with string manipulation.
14. Concatenate Strings
Concatenation is the term used for appending one string to the end of another string. Start by creating concatenation.sh file.
nano concatenation.sh
The most simple example would be the following:
#!/bin/bash
firststring="The secret is..."
secondstring="Bash"
thirdstring="$firststring$secondstring"
echo "$thirdstring"
The above script will connect the values of firststring and secondstring variables creating a whole new thirdstring.
A more advanced example would look like this:
#!/bin/bash
firststring="The secret is..."
firststring+="Bash"
echo "$firststring"
The script uses the += operator to join the strings. With this method, you can concatenate strings with only one variable.
15. Check if a Number is Even or Odd
Odd and even numbers can be easily divided using the if statement and some simple math. Create a file named evenoddnumbers.sh:
nano evenoddnumbers.sh
The script uses the read command to read user input and divides it by 2. If the answer is 0, the number is even.
#!/bin/bash
read -p "Enter a number and I will check if its odd or even " mynumber
if [ $((mynumber%2)) -eq 0 ]
then
echo "Your number is even"
else
echo "Your number is odd."
fi
16. Generate Factorial of Number
The factorial of a number is the result of all positive descending integers. For example, the factorial of 5 would be 120:
5! = 5*4*3*2*1 = 120
Factorial scrips are very useful for users learning about recursion. Start by creating a .sh file executable:
factorial.sh
The following script will ask the user to enter a number they want to get the factorial of and use a for loop to calculate it.
#!/bin/bash
echo Enter the number you want to get factorial for
read mynumber
factorial=1
for ((i=1;i<=mynumber;i++))
do
factorial=$(($factorial*$i))
done
echo $factorial
The command-line window displaying shell script for getting factorial of a number
17. Create Directories
It is effortless to create directories in bash unless you need to create a lot of directories quickly. In the following example, we will use the bash script to create a set of directories with the same subdirectories in each.
First, create a file named directories.sh:
nano directories.sh
Then paste in the following code:
#!/bin/bash
mkdir -p {Math,English,Geography,Arts}/{notes,examresults,portfolio}
The script creates 4 main directories: Math, English, Geography, and Arts. The Notes, examresults, and portfolio subdirectories are also created inside each.
If you were to replace the / symbol in the middle with _, the script would look like this:
#!/bin/bash
mkdir -p {Math,English,Geography,Arts}_{notes,examresults,portfolio}
Here’s the output for it displaying a merge of the two directories:
A bash script to create a lot of directories quickly. The first bash case statement indicates which interpreter to use
#!/bin/bash
#Declare string S1
S1="Bash"
#Declare string S2
S2="Scripting"
if [ $S1 = $S2 ]; then
echo "Both Strings are equal"
else
echo "Strings are NOT equal"
fi
The following script will check to see if a file exists or not.
#!/bin/bash
file="./file"
if [ -e $file ]; then
echo "File exists"
else
echo "File does not exist"
fi
The result:
$ ./filetesting.sh
File does not exist
$ touch file
$ ./filetesting.sh
File exists
Similarly for example we can use while loop to check if file does not exist. This script will sleep until file does exist. Note bash negator ! which negates the -e option.
#!/bin/bash
while [ ! -e myfile ]; do
# Sleep until file does exists/is created
sleep 1
done
Bash Select
The select command allows us to prompt the user to make a selection.
#!/bin/bash
PS3='Choose one word: '
# bash select
select word in "linux" "bash" "scripting" "tutorial"
do
echo "The word you have selected is: $word"
# Break, otherwise endless loop
break
done
exit 0
The result:
$ ./select.sh
1) linux
2) bash
3) scripting
4) tutorial
Choose one word: 2
The word you have selected is: bash
Case statement conditional
The case statement makes it easy to have many different possibilities, whereas an if statement can get lengthy very quickly if you have more than a few possibilities to account for.
#!/bin/bash
echo "What is your preferred programming / scripting language"
echo "1) bash"
echo "2) perl"
echo "3) phyton"
echo "4) c++"
echo "5) I do not know !"
read case;
#simple case bash structure
# note in this case $case is variable and does not have to
# be named case this is just an example
case $case in
1) echo "You selected bash";;
2) echo "You selected perl";;
3) echo "You selected phyton";;
4) echo "You selected c++";;
5) exit
esac
The result:
$ ./case.sh
What is your preferred programming / scripting language
1) bash
2) perl
3) phyton
4) c++
5) I do not know !
3
You selected phyton
Bash quotes and quotations
Quotations and quotes are important part of bash and bash scripting. Here are some bash quotes and quotations basics.
Escaping Meta characters
Before we start with quotes and quotations we should know something about escaping meta characters. Escaping will suppress a special meaning of meta characters and therefore meta characters will be read by bash literally. To do this we need to use backslash \ character. Example:
#!/bin/bash
#Declare bash string variable
BASH_VAR="Bash Script"
# echo variable BASH_VAR
echo $BASH_VAR
#when meta character such us "$" is escaped with "\" it will be read literally
echo \$BASH_VAR
# backslash has also special meaning and it can be suppressed with yet another "\"
echo "\\"
Here’s what it looks like when we execute the script:
$ ./escape_meta.sh
Bash Script
$BASH_VAR
\
Single quotes
Single quotes in bash will suppress special meaning of every meta characters. Therefore meta characters will be read literally. It is not possible to use another single quote within two single quotes not even if the single quote is escaped by backslash.
#!/bin/bash
# Declare bash string variable
BASH_VAR="Bash Script"
# echo variable BASH_VAR
echo $BASH_VAR
# meta characters special meaning in bash is suppressed when using single quotes
echo '$BASH_VAR "$BASH_VAR"'
The result:
$ ./single_quotes.sh
Bash Script
$BASH_VAR "$BASH_VAR"
Double quotes
Double quotes in bash will suppress special meaning of every meta characters except $, \ and `. Any other meta characters will be read literally. It is also possible to use single quote within double quotes. If we need to use double quotes within double quotes bash can read them literally when escaping them with \. Example:
#!/bin/bash
#Declare bash string variable
BASH_VAR="Bash Script"
# echo variable BASH_VAR
echo $BASH_VAR
# meta characters and its special meaning in bash is
# suppressed when using double quotes except "$", "\" and "`"
echo "It's $BASH_VAR and \"$BASH_VAR\" using backticks: `date`"
The result:
$ ./double_quotes.sh
Bash Script
It's Bash Script and "Bash Script" using backticks: Thu 10 Feb 2022 10:24:15 PM EST
Bash quoting with ANSI-C style
There is also another type of quoting and that is ANSI-C. In this type of quoting characters escaped with \ will gain special meaning according to the ANSI-C standard.
\a alert (bell) \b backspace
\e an escape character \f form feed
\n newline \r carriage return
\t horizontal tab \v vertical tab
\\ backslash \` single quote
\nnn octal value of characters ( see [http://www.asciitable.com/ ASCII table] ) \xnn hexadecimal value of characters ( see [http://www.asciitable.com/ ASCII table] )
One day, a little girl named Lily found a needle in her room. She knew it was difficult to play with it because it was sharp. Lily wanted to share the needle with her mom, so she could sew a button on her shirt.
Lily went to her mom and said, "Mom, I found this needle. Can you share it with me and sew my shirt?" Her mom smiled and said, "Yes, Lily, we can share the needle and fix your shirt."
Together, they shared the needle and sewed the button on Lily's shirt. It was not difficult for them because they were sharing and helping each other. After they finished, Lily thanked her mom for sharing the needle and fixing her shirt. They both felt happy because they had shared and worked together.
<|endoftext|>
Once upon a time, there was a little car named Beep. Beep loved to go fast and play in the sun. Beep was a healthy car because he always had good fuel. Good fuel made Beep happy and strong.
One day, Beep was driving in the park when he saw a big tree. The tree had many leaves that were falling. Beep liked how the leaves fall and wanted to play with them. Beep drove under the tree and watched the leaves fall on him. He laughed and beeped his horn.
Beep played with the falling leaves all day. When it was time to go home, Beep knew he needed more fuel. He went to the fuel place and got more healthy fuel. Now, Beep was ready to go fast and play again the next day. And Beep lived happily ever after.
<|endoftext|>
One day, a little fish named Fin was swimming near the shore. He saw a big crab and wanted to be friends. "Hi, I am Fin. Do you want to play?" asked the little fish. The crab looked at Fin and said, "No, I don't want to play. I am cold and I don't feel fine."
Fin felt sad but wanted to help the crab feel better. He swam away and thought of a plan. He remembered that the sun could make things warm. So, Fin swam to the top of the water and called to the sun, "Please, sun, help my new friend feel fine and not freeze!"
The sun heard Fin's call and shone its warm light on the shore. The crab started to feel better and not so cold. He saw Fin and said, "Thank you, little fish, for making me feel fine. I don't feel like I will freeze now. Let's play together!" And so, Fin and the crab played and became good friends.
<|endoftext|>
Once upon a time, in a land full of trees, there was a little cherry tree. The cherry tree was very sad because it did not have any friends. All the other trees were big and strong, but the cherry tree was small and weak. The cherry tree was envious of the big trees.
One day, the cherry tree felt a tickle in its branches. It was a little spring wind. The wind told the cherry tree not to be sad. The wind said, "You are special because you have sweet cherries that everyone loves." The cherry tree started to feel a little better.
As time went on, the cherry tree grew more and more cherries. All the animals in the land came to eat the cherries and play under the cherry tree. The cherry tree was happy because it had many friends now. The cherry tree learned that being different can be a good thing. And they all lived happily ever after.
<|endoftext|>
Once upon a time, there was a little girl named Lily. Lily liked to pretend she was a popular princess. She lived in a big castle with her best friends, a cat and a dog.
One day, while playing in the castle, Lily found a big cobweb. The cobweb was in the way of her fun game. She wanted to get rid of it, but she was scared of the spider that lived there.
Lily asked her friends, the cat and the dog, to help her. They all worked together to clean the cobweb. The spider was sad, but it found a new home outside. Lily, the cat, and the dog were happy they could play without the cobweb in the way. And they all lived happily ever after.
<|endoftext|>
Once upon a time, in a big lake, there was a brown kayak. The brown kayak liked to roll in the water all day long. It was very happy when it could roll and splash in the lake.
One day, a little boy named Tim came to play with the brown kayak. Tim and the brown kayak rolled in the water together. They laughed and had a lot of fun. The sun was shining, and the water was warm.
After a while, it was time for Tim to go home. He said goodbye to the brown kayak and gave it a big hug. The brown kayak was sad to see Tim go, but it knew they would play together again soon. So, the brown kayak kept rolling in the water, waiting for the next fun day with Tim.
<|endoftext|>
Once upon a time, in a small town, there was a troubled little girl named Lily. She was always sad because she lost her favorite toy, a triangle. She looked everywhere in her house but could not find it.
One sunny day, Lily went to the park to play. She saw a big puddle of water and thought her triangle might be there. She put her hand in the water to soak it and looked for her toy. She felt something at the bottom of the puddle.
Lily pulled it out and saw that it was her triangle! She was so happy that she found it. From that day on, Lily was never troubled again. She played with her triangle every day and always kept it close to her. And when she saw puddles, she would smile and remember how she found her toy.
<|endoftext|>
Once upon a time, in a peaceful town, there lived a little boy named Tim. Tim loved to run and play outside. One day, Tim saw a race in the park. He was excited and wanted to join the race.
Tim went to his friend, Sarah, and said, "Let's start the race!" Sarah smiled and said, "Yes, let's go!" They lined up with the other kids and waited for the race to begin. When they heard the word "Go!", they started running as fast as they could.
Tim and Sarah ran with all their speed, laughing and having fun. They could feel the wind in their hair as they raced to the finish line. In the end, Tim won the race and Sarah came in second. They were both so happy and proud of themselves. They celebrated with their friends and had a great day at the park.
<|endoftext|>
Once upon a time, there was a clever little dog named Max. Max loved to run and play with his friends in the park. One day, Max was running very fast when he fell and hurt his knee.
Max went to his friend, the wise old owl, and said, "Owl, my knee hurts. What can I do?" The owl thought for a moment and said, "Max, you should test your knee. Try to walk slowly and see if it still hurts."
So Max tested his knee by walking slowly. At first, it hurt a little, but soon Max felt better. He said, "Thank you, Owl, for your help. Now I can play with my friends again."
Max was so happy that he could play with his friends without pain. He learned that sometimes, it was good to slow down and listen to his body. And Max and his friends played happily in the park ever after.
<|endoftext|>
One day, a fast driver named Tim went for a ride in his loud car. He loved to speed down the street and feel the wind in his hair. As he drove, he saw his friend, Sam, standing by the road.
"Hi, Sam!" Tim called out. "Do you want to go for a ride?"
"Yes, please!" Sam said, and he got in the car. They drove around the town, going fast and having fun. The car was very loud, and everyone could hear them coming.
At last, they stopped at the park to play. They ran and laughed until it was time to go home. Tim and Sam had a great day together, speeding in the loud car and playing in the park.
<|endoftext|>
Once upon a time, there was a big car named Dependable. He had a very important job. Dependable would take a family to the park every day. The family had a mom, dad, and a little girl named Lily. They all had a lot of love for each other.
One day, when they got to the park, they saw a big sign that said, "Fun Race Today!" The family was very excited. They knew that Dependable was very fast and could win the race. So, they decided to join the race.
The race started, and Dependable went very fast. The other cars tried to catch up, but Dependable was too quick. In the end, Dependable won the race! The family was so happy and proud of their car. They knew that their love for each other and their trust in Dependable made them win the race. And from that day on, they had even more fun at the park, knowing that they had the fastest and most dependable car around.
<|endoftext|>
Once upon a time, there was a boy named Tim. He liked to wear a big, dark hat. The hat was his favorite thing to wear. Tim wore the hat everywhere he went.
One day, Tim found a pencil on the ground. The pencil was small and yellow. Tim liked the pencil a lot. He put the pencil in his hat and took it with him.
Tim drew pictures with the pencil. He drew a sun, a tree, and a cat. Tim was very happy with his new pencil. He wore his dark hat and drew pictures every day.
<|endoftext|>
One day, a girl named Mia went for a walk. She saw a big, scary house. It had a tall door and small windows. Mia was brave, so she went inside the house.
In the house, Mia saw a birdcage. Inside the birdcage, there was a little bird. The bird was sad. It wanted to fly and be free. Mia wanted to help the bird.
Mia opened the birdcage door. The bird flew out and was happy. It was not scary anymore. Mia and the bird were friends. They played and had fun all day.
<|endoftext|>
Once upon a time, in a small house, there lived a little girl named Amy. Amy was very sleepy. She put on her pajamas and went to bed.
In the middle of the night, Amy heard a soft sound. She opened her eyes and saw a friendly ghost. The ghost said, "Hello, Amy! I am here to help you."
Amy asked the ghost, "Can you help me pick a dream?" The ghost smiled and said, "Of course! Let's pick a happy dream for you." Together, they picked a dream about playing in a big park with lots of friends.
Amy said, "Thank you, ghost!" The ghost smiled and said, "You're welcome. Now, go back to sleep and enjoy your dream." Amy closed her eyes, feeling happy and safe with her new friend.
And so, Amy had a wonderful dream, thanks to the kind ghost. From that night on, the ghost would always visit Amy and help her pick the best dreams, and they became the best of friends.
<|endoftext|>
Once upon a time, in a big forest, there was a tiny mushroom. It was all alone. The sun was very harsh, and the mushroom did not like it. It wanted to find a friend to play with and to help it hide from the sun.
One day, a little bunny came hopping by. The mushroom called out, "Hello, bunny! Will you be my friend?" The bunny looked at the mushroom and smiled. "Sure, I will be your friend. Let's play together!" The bunny and the mushroom played all day, and they were very happy.
As they played, the bunny realized that the mushroom needed help to hide from the harsh sun. So, the bunny dug a hole in the ground and put the mushroom inside. Now, the mushroom was safe and cool. The mushroom and the bunny were the best of friends, and they played in the forest every day.
<|endoftext|>
Once upon a time, there was a queen. She was a very nice queen. She had a big, pretty castle. The queen had a lot of work to do every day. But today, she wanted to relax.
The queen went to the park to relax. She sat on a soft, green grass. The queen saw a bug. The bug was disgusting. The queen did not like the disgusting bug.
The queen went back to her castle. She was happy to be away from the disgusting bug. Now, the queen could relax in her big, pretty castle. The queen smiled and had a good day.
<|endoftext|>
Once upon a time, there was a little white cat named Fluffy. Fluffy loved to play with her best friend, a small boy named Timmy. They played outside in the sun every day. Fluffy liked to chase Timmy, and Timmy liked to run.
One day, Timmy learned a new word at school. He wanted to teach Fluffy the word too. Timmy said, "Fluffy, the word is 'repeat'. Can you say 'repeat'?" Fluffy looked at Timmy and said, "Meow." Timmy laughed and said, "No, Fluffy, say 'repeat'."
Fluffy tried again and said, "Meow-peat." Timmy clapped his hands and said, "Good job, Fluffy! You said the word!" Fluffy was very happy. She liked learning new words with Timmy. From that day on, Fluffy and Timmy played a game where they would teach each other new words. They had lots of fun together, and they lived happily ever after.
<|endoftext|>
Once upon a time, there was a big octopus. He lived in the deep blue sea. He had a friend, a reliable fish. They played together every day.
One day, the octopus and the fish found a big jug. They wanted to pour water on their friends for fun. But they couldn't agree on who would pour the water. The octopus said, "I want to pour the water!" The fish said, "No, I want to pour the water!" They were not happy.
Then, the octopus had an idea. He said, "Let's both pour the water!" The fish liked the idea. They picked up the big jug together and poured water on all their friends. Everyone laughed and had fun. The octopus and the fish were happy again. They learned to share and play together. And they lived happily ever after.
<|endoftext|>
One day, a silly cat named Tom found a hoop in the yard. He wanted to play with it, but it was too big. Tom thought very hard about how to make the hoop smaller.
Tom had an idea. He would stretch the hoop to make it smaller. He put his paws on the hoop and pulled as hard as he could. The hoop started to stretch! It got smaller and smaller.
Now, the hoop was just the right size for Tom to play with. He jumped through the hoop and chased it around the yard. Tom had so much fun playing with his new toy. And that is the story of the silly cat and the hoop.
<|endoftext|>
Once upon a time, there was a polite crab. The crab lived in the sea. The crab had many friends.
One day, the crab met a new friend. The new friend did not know how to play. The crab wanted to help the new friend.
The polite crab showed the new friend how to play. They played all day. They had lots of fun. The new friend was happy. The polite crab was happy too. They were best friends forever.
<|endoftext|>
Once, there was a boy named Tim. Tim liked to fish. He had a long pole to catch fish. One day, his friend Sam came to play. Sam saw the pole and asked, "Can you lend me your pole?" Tim said, "Yes, but be careful!"
Sam took the pole and went to the river. He tried to catch a fish. He saw a big, yummy fish. He wanted to catch it. He pulled the pole very hard. But the pole broke! Sam felt sad.
Sam went back to Tim with the broken pole. He said, "I am sorry, I broke your pole." Tim was very sad. Now, he could not catch yummy fish. They both learned to be more careful with their things.
<|endoftext|>
Once upon a time, in a small house, there lived a boy named Tim. Tim was a selfish boy. He did not like to share his things with others. One day, his mom brought home a big bag of vegetables. She wanted to explain to Tim why it was important to share.
"Tim," said Mom, "we need to share these vegetables with our neighbors. It is not good to be selfish." Tim did not want to share the vegetables. He wanted to keep them all for himself. But Mom told him, "If you share, you will make others happy."
Tim thought about it and then said, "No, I don't want to share." So, he took the vegetables and hid them in his room. The neighbors were sad because they had no food to eat. They knocked on Tim's door and asked if he had any food to share. Tim did not want to share, so he said no.
That night, Tim ate all the vegetables by himself. He felt very full and sick. He wished he had listened to his mom and shared with the neighbors. But now, it was too late. The vegetables were gone, and Tim felt very bad.
<|endoftext|>
Once upon a time, there was a girl named Sue. Sue had long hair that would remind her of a rainbow. She would play with her hair all day.
One day, Sue saw a slow snail in her garden. The snail had a pretty shell. Sue wanted to be friends with the snail. She named the snail Sam.
Sue and Sam played together every day. They would race, but Sam was always slow. Sue would laugh and clap her hands. Sue and Sam were very happy.
<|endoftext|>
Once upon a time, there was a helpful girl named Lily. She loved to read books and spend time with her friends. One day, she found a new book at school. The book was about a kind bear who helped everyone in the forest.
Lily read the book to her friends. They all liked the story. They wanted to be like the kind bear in the book. So, they decided to help others too. They helped their teacher clean the classroom. They also helped their friends when they fell down or needed a friend to play with.
As they spent more time being helpful, Lily and her friends felt happy. They learned that being kind and helpful to others made them happy too. The moral of the story is to be kind and helpful, just like the kind bear in the book.
<|endoftext|>
Once upon a time, there was a little boy named Tim. Tim wanted to build something special for his mom's birthday. He thought and thought about what to make. Then, he had an idea! He would build a big present for her.
Tim was worried. He didn't know if he could build the present all by himself. He asked his dad for help. Together, they found some big boxes, pretty paper, and a big bow. They worked together to make the present look nice.
When Tim's mom saw the present, she was so happy! She gave Tim a big hug and thanked him for the special gift. Tim felt proud that he could build something so nice for his mom. And he was no longer worried.
<|endoftext|>
One day, a big whale was swimming in the deep blue sea. The whale was very mysterious. It had a big smile on its face and liked to play with the little fish.
The mysterious whale loved to relax in the warm water. It would lay on its back and let the waves rock it like a baby. The little fish would swim around the whale, and they all felt happy and safe.
One day, the mysterious whale and the little fish found a beautiful place to relax. It was a quiet spot with lots of colorful plants and pretty shells. They all had a fun day, playing and relaxing together in their new secret place.
<|endoftext|>
Once upon a time, there was a smelly old tree. By the tree, there was a big hole. In the hole, there was a shiny coin. A boy named Tim saw the coin and wanted it.
Tim said to his friend, "I want that coin, but the tree is smelly and rot." His friend said, "Be brave, Tim! You can get the coin." So, Tim went to the smelly tree and tried to get the coin from the hole.
As Tim got closer to the hole, he saw a little mouse. The mouse said, "I will help you get the coin, but you must help me too." Tim agreed, and they got the coin together. Tim was happy, and the mouse was happy too. And they both learned that even in smelly places, good things can happen.
<|endoftext|>
Once upon a time, there was a little boy named Tim. Tim loved going to the park to play. One day, Tim went to the park with his mom and dad. He was very happy.
At the park, Tim saw a big tree. He wanted to give the tree a hug. So, he hugged the tree and felt good. Tim liked the tree a lot. He played with his ball, ran around, and had a lot of fun.
Tim had a successful day at the park. He played and laughed a lot. When it was time to go home, Tim felt tired but happy. He couldn't wait to come back to the park again.
<|endoftext|>
One sunny day, a pretty boat was on the water. The boat was red and blue. A girl named Lily and her dog, Spot, were on the boat. They liked to play and have fun together.
Lily saw a big fish jump out of the water. She said, "Wow, Spot! Did you see that big fish?" Spot barked and wagged his tail. They both laughed and clapped their hands.
Lily picked up a hose and started to spray water. She sprayed the water on the boat and on Spot. Spot jumped and barked, trying to catch the water. They played and sprayed water until the sun went down. Then, they went home, happy and wet.
<|endoftext|>
Once upon a time, there was a girl named Lily. She had a flute that she loved to play. One day, she met a deaf cat who could not hear her play the flute. Lily wanted to help the cat hear her music.
Lily had an idea. She would stretch a big string from her flute to the cat's ear. The cat could feel the music through the string. The cat was happy and started to dance.
Lily and the deaf cat became best friends. They played and danced together every day. The cat loved to feel the music from Lily's flute. They were happy and had lots of fun.
<|endoftext|>
Once upon a time, there was a boy named Tom. He loved gum. One day, he found a thin piece of gum on the ground. He thought it was very special. He put the gum in his pocket to save it for later.
Tom went to play with his friend, Sam. They played a game where they had to escape from a pretend monster. They ran and hid, but the monster always found them. Tom felt scared, but he remembered his special gum. He thought it could help them win the game.
Tom took out the thin gum and shared it with Sam. They both chewed the gum and started to run from the monster again. But this time, they did not escape. The gum made them feel sick and slow. The monster caught them, and they lost the game. Tom and Sam were very sad. They learned never to pick up gum from the ground again.
<|endoftext|>
Once upon a time, there was a little boy named Tim. Tim had a favorite vest that he loved to wear. It was a pretty vest with many colors. He wore it all the time.
One day, it started to rain when Tim was playing outside. The rain made Tim and his vest very wet. Tim did not like being wet, so he went back inside his house. His mom saw his wet vest and told him to take it off.
Tim took off his wet vest and started to weep. He was sad because his favorite vest was wet. His mom saw him weep and hugged him. She told him not to worry, she would dry the vest. Tim felt better and played with his toys while he waited for his vest to dry.
<|endoftext|>
Once upon a time, there was a little boat. The boat was blue and it liked to float on the water. One day, the sun was very hot and the water began to dry up. The boat was sad because it could not float anymore.
A bird saw the boat and asked, "Why are you sad, little boat?" The boat said, "The water is dry and I cannot float. I miss the water." The bird wanted to help the boat, so it thought of an easy plan.
The bird told the boat, "I will find more water for you. Then you can float again!" The boat was happy and thanked the bird. The bird flew away and soon found a big pond. It came back and told the boat about the pond.
Together, the bird and the boat went to the big pond. The boat was able to float again and it was very happy. The bird and the boat played together in the water all day long. And they became the best of friends.
<|endoftext|>
Once upon a time, there was an old lady who lived in a small house. She loved to mix things in her big pot. One day, she decided to mix some yummy soup for her lunch.
As she mixed the soup, she saw some smoke come out of her pot. She knew that meant the soup was very hot. The old lady was very careful not to touch the smoke or the pot.
She let the soup cool down and then she ate it. The old lady thought it was the best soup she ever had. She was very happy and full. From that day on, she always mixed yummy soup for her lunch.
<|endoftext|>
Once upon a time, there was a little boy named Tim. Tim was very nervous. He had lost his toy razor. He loved to pretend to shave like his dad. Every day, he would play with his toy razor. But now, it was gone.
One day, Tim went to the park with his mom. He thought maybe he left his toy razor there. He looked and looked, but he could not find it. Tim was very sad. He missed his toy razor so much. He wanted to find it and play with it again.
Then, Tim saw a girl playing with a toy. He looked closer and recognized it. It was his toy razor! Tim was so happy. He went to the girl and told her that it was his toy. The girl was nice and gave it back to him. After that, Tim was not nervous anymore. He had his toy razor back and could play with it again. And they all lived happily ever after.
<|endoftext|>
Once upon a time, there was a big gray elephant named Elly. Elly was sad because she thought she was ugly. She had big ears and a long nose, and she felt different from the other animals.
One day, a little bird named Benny flew to Elly. Benny saw that Elly was sad and asked, "Why are you sad, Elly?" Elly told Benny that she felt ugly and did not like her big ears and long nose. Benny looked at Elly and said, "I think you are not ugly. You are special."
Benny promised to show Elly how her big ears and long nose made her special. They went to the river, and Benny asked Elly to use her long nose to spray water on the dry plants. Elly did and the plants grew happy and green. Then, Benny asked Elly to use her big ears to fan the hot animals. Elly did, and all the animals felt cool and happy.
Elly learned that being different was not ugly. She was special and had her own way to help others. Elly and Benny became best friends, and they lived happily ever after.
<|endoftext|>
Once upon a time, there was a little dog named Zigzag. Zigzag loved to run and play in the park. One day, Zigzag saw a big twisty slide. He wanted to try it, so he ran up to the slide.
Zigzag twisted and turned as he went down the slide. He went so fast that he fell off at the end. He felt embarrassed because all his friends saw him fall. But his friends did not laugh at him. They ran to help Zigzag get up.
Zigzag's friends told him not to be embarrassed. They all tried the twisty slide, too. They all twisted and turned, just like Zigzag. They had so much fun playing together. And Zigzag learned that it's okay to make mistakes, as long as you have good friends by your side.
<|endoftext|>
Once upon a time, in a small house, there was a cat and a dog. They liked to play all day. One day, they saw a shiny chain on the floor. They both wanted it.
The cat had an idea. She rubbed her head on the dog's leg. The dog felt happy and closed his eyes. The cat took the chain and ran away. The dog felt sad and guilty.
Later, the cat felt bad. She went back to the dog and gave him the chain. They both played with the chain and were happy friends again.
<|endoftext|>
One day, a little boy named Tim went to play outside. He saw a big box near the tree. Tim was very curious. He wanted to know what was inside. So, he went closer to the box and took a peek.
Inside the box, Tim found a toy gun. He was so happy! He picked up the gun and started to play with it. He pretended to be a superhero, saving the world from bad guys. Tim ran around the yard, laughing and having fun.
After playing for a while, Tim started to feel hungry. He went back to his house and saw his mom in the kitchen. She had made some yummy cookies for him. Tim ate the cookies and told his mom about the toy gun and his adventures. His mom smiled and gave him a big hug.
<|endoftext|>
One day, a boy named Tim found a big hammer in his toy box. He took the hammer and went to play in the deep mud outside. While he was playing, he saw a little bug stuck in the mud.
"Help me, please!" said the bug. Tim wanted to help, but he didn't want to delay his playtime. The bug looked very sad, so Tim decided to help.
Tim used his big hammer to make a path in the mud. The bug was able to crawl out and said, "Thank you, Tim!" Tim felt happy that he helped the bug. After that, he continued playing with his hammer, but now he also had a new friend to play with.
<|endoftext|>
Once upon a time, in a small house, there was a big box. The box was empty. A little boy named Tim wanted to find something to put in the box. He started to search his room.
Tim looked under his bed and found a soft toy. He pushed the toy into the box. Next, he searched in his closet and found a ball. He pushed the ball into the box too. Tim was happy to see his box filling up.
After a while, the box was full. Tim felt proud of his search. He showed his mom and dad the full box. They smiled and clapped. Tim had turned the empty box into a box filled with fun things.
<|endoftext|>
Once upon a time, in a big, green park, there was a small, messy dog named Binky. Binky had a long, waggy tail and loved to play with his friends. One sunny day, Binky and his friends were playing catch with a big, red ball.
As they played, Binky's tail got caught in a bush. "Ouch!" he cried. Binky's friends heard him cry and came running to help. "What's wrong, Binky?" asked his friend, a cute, fluffy bunny named Lulu.
"My tail is stuck!" Binky said with a sad face. Lulu and the other friends tried to help Binky get his tail out of the bush. They pulled and pulled, but it was still stuck.
Then, a wise, old owl named Oliver flew down from a tall tree. "Don't cry, Binky," he said. "I can help you get your tail out." Oliver used his sharp beak to carefully cut the bush and free Binky's tail.
Binky was so happy! He wagged his tail and said, "Thank you, Oliver!" All the friends cheered and clapped. Then, they went back to playing with the big, red ball, laughing and having fun together.
<|endoftext|>
Once upon a time, in a small town, there was a little boy named Tim. Tim loved to speak and play with his friends. One day, Tim found a big, pink gum on the ground. It looked amazing. Tim picked it up and put it in his pocket. He thought, "I will show this to my friends later."
Tim went to the park to play with his friends. He saw them playing and running. Tim took the gum out of his pocket and showed it to his friends. They all wanted to see the amazing gum. Tim told them, "I found it on the ground. It looks amazing, right?" His friends nodded and smiled.
Later, Tim and his friends sat under a big tree. They all looked at the gum and talked about how amazing it was. Then, they decided to share the gum. They broke it into small pieces and each took a piece. They chewed the gum and it was very yummy. They all laughed and spoke about how great the gum was. Tim was happy that he found the amazing gum and could share it with his friends.
<|endoftext|>
Once upon a time, there was a little boy named Tim. Tim loved pumpkins. He loved their round shape and bright orange color. One day, Tim saw a small pumpkin in the garden. It was not clear if the pumpkin was ready to be picked.
Tim asked his mom, "Can I receive this pumpkin, please?" His mom looked at the pumpkin and said, "It is not ready yet. You must wait for it to grow bigger."
Tim waited and watched the pumpkin grow. As it grew, he learned to be patient. He knew that good things come to those who wait. Finally, the day came when the pumpkin was big and ready to be picked.
Tim's mom said, "Now you can receive the pumpkin, Tim." Tim was so happy! He had waited and now he had a big, beautiful pumpkin. The moral of the story is that patience is a good thing. When we wait for the right time, we can receive the best things in life.
<|endoftext|>
Once upon a time, there was a little girl named Lily. She lived in a small house with her mom and dad. One day, her mom asked her to go to the park and play. Lily was very happy and ran to the park.
At the park, Lily saw a wide tree. She went to the tree and saw a faucet. She turned the faucet and water came out. Lily was thirsty, so she drank some water. Then, she saw a little boy who was also thirsty. Lily said, "Hi, I am Lily. Let's be friends!" The little boy smiled and said, "Hi, I am Tom. Nice to meet you!" They both drank water and played together.
Lily and Tom played and had fun all day. They learned that it is good to share and help others. When they went home, they told their moms and dads about their new friend. Lily and Tom were happy because they learned that sharing and helping others makes everyone happy.
<|endoftext|>
Once upon a time, there was a little flower named Bloom. Bloom lived in a big garden with many other flowers. Bloom had a goal to be the most beautiful flower in the garden.
One sunny day, Bloom saw a dangerous bug coming near the flowers. Bloom was scared and said to the other flowers, "Watch out! Dangerous bug is coming!" The other flowers thanked Bloom for the warning, and they all hid from the bug.
After the bug left, the flowers were safe and happy. Because Bloom warned them, they all agreed that Bloom was the most beautiful flower in the garden. Bloom's goal came true, and they all lived happily ever after.
<|endoftext|>
Once upon a time, in a small town, there lived a humble girl named Lily. She loved to give and help others. One day, she saw an old lady who looked sad.
Lily went to the lady and said, "Why are you sad?" The old lady said, "I am hungry, and I have no food." Lily wanted to help her, so she ran home to get some food.
Lily put some food on a plate and went back to the old lady. She gave the plate to the lady and said, "Here, eat this." The old lady smiled and said, "Thank you, Lily. You are very kind."
The old lady was happy, and Lily felt good that she could help. From that day on, Lily always looked for ways to help others and share what she had. And everyone in the town loved the humble girl who loved to give.
<|endoftext|>
Once upon a time, there was a little girl named Sue. Sue had a big bedroom with fancy things in it. She loved her room very much. One day, she saw a small flower in her room. The flower was trying to bloom.
Sue said to the flower, "Hello, little flower! Why are you trying to bloom in my bedroom?" The flower said, "I want to be a fancy flower in your room." Sue liked the idea, but she knew that flowers needed sun and water to grow.
Sue tried to help the flower. She gave it water and put it near the window. But the flower did not get enough sun. It tried very hard to bloom, but it could not. The flower became sad and said, "I am sorry, Sue. I cannot be a fancy flower in your room."
In the end, the flower did not bloom. It stayed small and sad. Sue felt bad for the flower. She wished she could help it more. But she knew that flowers needed sun and water to grow, and her bedroom was not the best place for a flower to live.
<|endoftext|>
Once upon a time, there was a little infant named Tim. He liked to play with his toys and watch the birds outside his window. Tim had a big, soft teddy bear that he loved very much.
One day, Tim's teddy bear was sad. Tim did not know why his teddy bear was sad. He tried to make his teddy bear happy by giving it a hug and a kiss.
Tim decided to take his sad teddy bear outside to watch the birds with him. They sat under a big tree and watched the birds sing and fly. Soon, the teddy bear was not sad anymore. Tim and his teddy bear were very happy watching the birds together.
<|endoftext|>
Once upon a time, in a small town, there was a little boy named Tim. Tim loved ice-cream so much. One day, he saw an ancient ice-cream truck. The truck was very old and slow, but it had a big sign that said "Ice-Cream".
Tim went to the truck and said, "Hi, can I have ice-cream, please?" The ice-cream man looked at him and said, "Sure, little boy. Here you go." Tim took the ice-cream and started to eat it. But it did not taste good at all. It tasted very bad.
Tim screamed, "Yuck! This ice-cream is bad!" The ice-cream man just laughed and said, "I am sorry, little boy. The ice-cream is too old." Tim was very sad and walked away. He did not get to enjoy his ice-cream that day.
<|endoftext|>
Once upon a time, there were two best friends, Joe and Grace. They were always playing together and having so much fun. One day, Joe and Grace decided to go to the town's marketplace.
When they got there, they saw a vendor with lots of colorful balloons. Joe wanted one so badly, but he didn't have enough money. Grace saw how sad Joe was and wanted to help. She asked her mom to bring some money so Joe could buy a balloon.
When Grace's mom arrived she saw that Joe wanted a deep red balloon. Joe was so relieved to be able to buy it after his friend helped him. Grace said to Joe, "Remember, if you help a friend in need, you will always be rewarded!"
Joe and Grace smiled and hugged each other, walked away with the deep red balloon, proud of the lesson they had learnt.
<|endoftext|>
Once there was a graceful bird called Billy. He was always looking for something to do. One day he decided to try something new. He wanted to weigh himself with a spoon.
Billy gathered his spoon and measured himself. He found that he was very light! He was happy with his weight and wanted to celebrate.
So he started to dance in the sky. His graceful moves caused even the clouds to watch. He spread his wings and flew higher, higher and higher until he was just a dot in the sky.
Billy went flying around the world. Then, one by one he started to pick up all the things he had weighed with the spoon. In the end, Billy was still the lightest and most graceful of them all!
<|endoftext|>
Once upon a time there were two friends, Jack and Jill. Jack and Jill went up the hill to play a game. The game was silly. Jack and Jill took turns pushing a big button. Every time they pushed the button they would separate.
Jack shouted: "Let's try again!" So they took turns pushing the button again. This time the button spun them around and around until they were dizzy.
Jill giggled and said: "That was so silly!"
Jack laughed and said: "Let's try the button one more time!" So they pressed the button again and this time it sent them soaring high into the sky!
Jack and Jill flew around, but eventually the button sent them back down to the ground. They were safe and sound, but something was different this time.
Jack and Jill were no longer together. The button had separated them! But it was all worth it in the end, because a silly game can bring people together in the most unexpected of ways.
<|endoftext|>
Once upon a time, there was a boy who loved to climb. One day, he decided to climb to the top of a mountain to get a better view. When he reached the peak, he saw a lake below him. It looked so inviting, so he decided to climb back down to the lake.
As soon as the boy got to the lake, he noticed a boat on the shore. He asked the boat, "Are you available?" The boat replied, "Yes, I am available for you to use." The boy was so excited! He couldn't wait to jump into the boat and go for a ride on the lake.
The boy took the boat out on the lake and had a wonderful time. But when he finished his ride, he noticed a sign near the shore. It said, "Take care of the boat; treat it with respect". The boy realized that it was not just available, it had been given to him to use with respect.
The moral of the story is that when given something, it should be treated with gratitude and respect. We should never take things for granted.
<|endoftext|>
Once, there was a girl. She had a garage. Inside the garage she kept her toys.
One day, the girl noticed something was wrong with her toys. She went in the garage and saw that they had broken.
She decided she would repair them and make them as good as new. She made sure to wash them all so they were nice and healthy.
Then she took some glue and fixed all the toys until they looked perfect. She was very pleased with her work.
When she was done, the girl could play with her toys again and have lots of fun. She was very happy.
<|endoftext|>
Mommy and Emily were playing a matching game together. Emily was so excited to find the matching games at the store. She liked watching the videos on the screen as she matched each card.
"Mommy, I think I'm getting really good at this!" Emily said.
"That's wonderful, sweetheart!" Mommy replied. "You're doing so well!"
But then, Emily noticed something strange. She pulled out one of the cards and looked closely at it.
"Mommy, this card isn't real," she said. "It's fake!"
Mommy took the card and looked at it. "You're right," she said. "This card is fake. It doesn't match the others."
Mommy and Emily decided to get a new video game instead. Emily was happy to have an even better game to play. She could tell the difference between a real card and a fake one.
<|endoftext|>
Once there was a little girl called Mia who loved to jump. Everywhere she went, she jumped. When walking to school, she would jump on the sidewalk. At the park, she would jump into the sandbox.
One day Mia was at the supermarket and she saw something unusual. She saw a lawyer. Mia had never seen a lawyer before so it made her very curious. She wanted to know what a lawyer did and why he was so dressed up. So, Mia jumped right up to the lawyer and asked him.
The lawyer was very confused. He had never seen a little girl so eager to talk to him. He tried to explain but Mia kept on jumping and interrupting.
Soon enough the store manager got involved. He explained to Mia that it was not appropriate to engage with strangers and it was wrong to interrupt people when they were talking.
Mia was very sorry for her behaviour and decided to never do something like this again. She had learned her lesson that it is important to be respectful to all strangers.
<|endoftext|>
Once there was a girl named Lucy. She was three years old and she loved gum. She had lots of different flavours and she ate it every day.
One day Lucy thought it would be fun to try extra big bubblegum. She put it in her mouth and blew a huge bubble. Suddenly, the bubble popped and tickled her nose. She started to sneeze and sneeze.
Lucy looked down and saw her shirt was covered in gum. She was so ashamed. She wanted to hide but couldn't.
So she asked for help from her parents. They showed her how to use a wet cloth to wipe the gum away. She smiled with relief and promised never to try big bubblegum again.
<|endoftext|>
Once, there was a small boy named Charlie. Charlie loved stories more than anything else. Charlie's mommy always said that stories were special and delicate.
One day, Charlie's mommy said "Let's go to the store and get something special for dinner. Today, you can have whatever you want to eat!"
Charlie was so excited! He wondered what he should pick. As they walked through the store, Charlie reached out and touched a strawberry. He asked his mommy, "What does this taste like?"
His mommy replied, "Oh, it's very sweet! If you taste it, you'll love it!"
Charlie was so excited! He couldn't wait to get home and have his special dinner.
When they arrived home, Charlie couldn't believe his eyes. On the table was a plate full of fresh strawberries! He smiled and said, "Mommy, did you know strawberries were my favorite?"
His mommy smiled and said, "I had a feeling you would like them! Go ahead and taste them, they are so delicate and sweet."
Charlie picked one up, took a bite, and smiled. He had experienced the special and delightful taste of a strawberry. What a delicious dinner!
<|endoftext|>
Once upon a time, there was a little girl named Cindy. Every day, Cindy would go to the store to get milk for her family. She loved the store and was always greeted by the friendly shopkeeper.
One day when Cindy was at the store, she noticed something strange: the shelves were all empty! She asked the shopkeeper why the shelves were empty. "It's too hard for you to understand," the shopkeeper said.
Cindy wasn't happy about this. But she had to trust the shopkeeper. So, she said goodbye and went home.
When Cindy told her family the news they didn't recognize the problem. But then they noticed something even more strange: the milk was gone too!
The family soon realized what had happened: the shopkeeper had been preparing for a snowstorm and had run out of milk. They were relieved that the shopkeeper had already taken care of the problem.
Cindy was happy that she had recognized the problem. Next time, she would know that she shouldn't leave getting milk too late.
<|endoftext|>
Jack was feeling a bit sad. He wanted some wine but he didn't have any. He walked up to a store and asked the shopkeeper, "Do you have any wine?"
The shopkeeper replied, "Yes, I have some. It's bad though. Are you sure you want it?"
Jack thought for a moment then said, "Yes, I will take it."
The shopkeeper counted out two bottles of wine and handed them to Jack. Jack thanked the shopkeeper and went home.
When Jack got home he opened a bottle of the bad wine and took a sip - it tasted horrible! He thought to himself, "Maybe I should have asked for something else!"
<|endoftext|>
Once upon a time, there was a little girl named Annie. She was only three years old but she was full of energy and liked to explore. One day, she was walking in the forest and came across a clearing. In the middle of the clearing was an arrow.
Annie was nosy and wanted to take a closer look. She walked up to the arrow and suddenly a voice shouted at her from behind, “Be careful not to touch it!” Annie jumped back in fright and saw an old man.
The old man said, “My name is Wilbur and I was just minding my own business when I saw you walking towards the arrow. I was worried that you may get injured, so I shouted.”
Annie smiled and said, “Thank you Wilbur, I will mind your advice."
Wilbur smiled back and replied, “That’s very wise young lady. Now why don’t we just run away and leave the arrow in peace?”
And so, Annie and Wilbur ran away. Annie learned that even if you are nosy, it is important to follow the advice of others and mind what you are doing.
<|endoftext|>
Once upon a time, there was a little girl who loved fashion. She spent all of her time imagining what it would be like to have the perfect outfit for her. Every day, she would go searching for new clothes that she could wear.
One day, she found the most perfect dress. It was her favourite colour, and it fit her perfectly. She was so excited, she decided to wear it that same day.
When she got to school, all the other students crowded around to admire her dress. She was so proud and happy. She knew that it was the best choice she had ever made.
But then her teacher told her she couldn't wear it. The dress was too fancy, too 'fit' for school. She felt so sad and embarrassed. Tears ran down her face, and she had to go home without her perfect dress.
The little girl was never able to wear her dress again. She still remembers it with sadness. She never imagined it would end this way.
<|endoftext|>
Once there were two friends named Bob and Sam. They were playing together in the garden one day. Sam picked a flower and then pointed to a black bird in a tree.
"What's that?" he asked Bob.
Bob smiled and said, "That's a Crow. Listen, what sound does it make?"
Suddenly, the crow made a loud sound that sounded like "Caw, Caw!"
"That's a Caw," Bob smiled.
Sam laughed and said, "I think I should pick a better word next time!"
Bob smiled and nodded. "That's a good idea. We should always pick the right word to use when we talk to each other."
The moral of the story is that it is important to choose the right words when you talk to your friends. Being thoughtful and using kind words can help keep friendships strong.
<|endoftext|>
One night, two brave animals were walking through a dark forest. The first animal was a big, strong bear. The second animal was a small, alert owl.
The owl said, "The trees are so dark here. I can barely see!"
The bear said, "Don't be scared, little owl. I'm here with you."
The owl said, "Thank you, bear. I feel safer with you here."
Suddenly, they heard a loud noise. The bear started to tremble. He said, "Let's leave this place! Quickly!"
The owl got alert and flapped its wings. Together, they ran through the forest until they emerged into the night sky, safe and sound.
The bear hugged the owl and said, "We did it! We made it out of there together."
The owl smiled and said, "Yes, we did."
The two animals laughed happily. From then on, they were the best of friends.
<|endoftext|>
Once upon a time there was a kitty who liked to play with a special brush. Each day, the kitty would lend the brush to a friend in the park. Every day, the kitty was so careless with the brush that it got lost.
One day, the kitty was playing in the park when it saw its special brush with a rabbit. The kitty asked the rabbit if he could lend the brush.
The rabbit said, "If you want the brush back, then you must be careful and not let it get lost again!" The kitty agreed and happily went off with the brush.
The kitty was very careful with the brush from then on. In fact, the kitty was so careful that it never lost the brush again. Everyone in the park was happy to hear this and the kitty lived happily ever after.
<|endoftext|>
Once, there was a little girl named Ella. She was very excited, because today was a very special day.
Ella grabbed her toys and her backpack. Then, she stepped out of her house and started walking.
Ella followed the pathway until she reached a big, red stove in the middle of the forest. It was very unique! Ella looked around and saw nobody.
Ella stepped closer to the stove and asked, "Who are you?".
Suddenly, out of nowhere, Ella heard a voice. It was coming from the stove. It said, "I'm a magical stove! I can grant you three wishes!".
Ella was baffled. But she was also excited about her wishes. She thought for a short moment and made her wishes.
The magical stove granted all of Ella's wishes in an instant. Ella was so happy. She thanked the magical stove and stepped back, returning to her home.
From that moment on, Ella was sure that her wishes would come true. She knew that she had met something very unique that day.
<|endoftext|>
Once upon a time, there was a caterpillar called Bill. He had 8 small legs and loved exploring in the garden.
One day, Bill was walking around when he heard a noise in the bushes. Curious, he crept closer to take a look.
Suddenly, a big, tough frog jumped out from the bushes. Bill was so scared, he blinked his eyes and scurried away.
The frog bellowed "Where are you going? Don't be a scaredy-cat!"
It made Bill feel better as he stopped and said shyly, "I'm sorry, I thought you were scary."
The frog smiled and said, "There's nothing wrong with being scared, just always be brave and face your fear. Everyone gets scared sometimes."
Bill smiled back, thanked the frog, and continued his adventure. He soon realized that sometimes, being brave and facing tough things can be quiet rewarding.
From that day forth, Bill always remembered the frog's advice and faced his fear, no matter how tough it seemed.
<|endoftext|>
Once upon a time, there was a baby who wanted to pick something special. He went to a shop and saw an ancient case. He picked it up and looked inside. It was full of unbelievably shiny gems and jewels. He couldn't believe his eyes. He was so excited and he knew this case was perfect. He quickly picked it up and wrapped it up with a big red bow. He smiled and couldn't wait to show his mum and dad. He rushed home and when they saw the case they were so surprised. He was so proud and he knew this case was very special. He kept it on his shelf for all to see. Everyone was so amazed by the ancient case.
<|endoftext|>
Once there was a naughty little girl. She was very naughty and always misbehaving. One day she do something very naughty. She took her daddy’s tie and put it in the dirt. It began to rot away in the soil.
The little girl felt very bad about what she’d done, but it was too late. The tie was ruined and couldn’t be fixed.
The little girl’s daddy was very sad. He had worked very hard to buy that tie, and now it was gone. The little girl knew she had done something wrong and she was sorry.
The daddy gave the little girl a big, big hug and said it was alright. He said he still loved her and that she must never do such a naughty thing again.
The little girl was very happy and promised to never do anything naughty again. And with that, the tie was forgotten and the little girl was happy once more.
<|endoftext|>
Jim was very frightened when he arrived at the barber's shop. It was his first time getting a haircut! He didn't want his mum to leave him alone with the strange man.
"Don't worry," said the barber. He smiled and handed Jim a big lollipop. "I'll look after you and give you the best haircut ever."
Jim's frown disappeared and he couldn't help but be excited. The barber put a cape around him, and the chair felt like a magic carpet ride. Soon, Jim felt his hair being trimmed, and the barber even gave him some funny glasses to look through. When Jim looked in the mirror, he saw the best haircut ever! He was so happy, he forgot all about being scared.
Mum smiled when she saw Jim. She was so proud of him for sitting so still for such a long time.
"Well done, my boy!" she said, giving him a big hug.
Jim smiled and couldn't wait to show his friends his new haircut.
<|endoftext|>
One cold winter day, Tilly was outside helping in the garden. She grabbed a rake and started cleaning up the leaves on the ground. She held the rake in front of her and carefully balanced the leaves. The ground was icy so Tilly took some small steps to steady herself.
Tilly carefully moved the rake back and forth against the ground, pushing the leaves into a pile. She smiled as the pile grew bigger. She even found some shiny objects under the leaves.
When she was finished, Tilly stood back and admired her work. The ground was so clean and tidy. Tilly was so proud of herself. She gave herself a big hug to celebrate.
Tilly grabbed her rake, feeling warm and happy inside. She had done an amazing job with the rake and was super proud of herself.
<|endoftext|>
Once upon a time there was an adorable little rabbit. His mommy told him to rake the leaves in the garden. So he raked and raked but it was a lot of work and he got tired very quickly.
His daddy saw him struggling and decided to help him. He took the rake and together they finished raking the garden in no time.
After they finished, his daddy said to him, "Helping each other can make chores seem like less of a chore. It's so much nicer to do them together, isn't it?".
The adorable little rabbit nodded and smiled in agreement. Then his mommy asked him to wipe the table and the two of them wiped it together.
In the end, the little rabbit learned a valuable lesson: when you have big tasks ahead of you, it's okay to ask for help. Working together makes chores much easier!
<|endoftext|>
Once upon a time there was a brother and sister who loved to play together. One day they went to the park and saw the most interesting mug. It was big, colourful and looked like it belonged to a magical creature. The brother was very tempted to steal it but the sister was obedient and wouldn't let him.
The brother said "Come on, just take it! It'll be fun!"
The sister replied firmly "No! That would be wrong, stealing is not allowed!"
Eventually, the brother listened to his sister and put the mug back. Both of them were glad that they had been obedient and followed the rules. After that, they ran off and played their favourite game.
The End.
<|endoftext|>
Once upon a time, there was a tall fox who lived in the forest. She was very curious, and every day she liked to study the forest animals. One day, she asked a rabbit who was hopping by, "Do you know what I study every day?"
The rabbit looked up and said, "No, I don't know, what do you study?".
The fox replied, "I like to study the animals that live in the forest. I like to find out how they live and what they do."
The rabbit said, "That sounds very interesting! I wish I could study too."
The fox smiled and said, "You can. Just come with me tomorrow, and I will show you how to study the animals in the forest".
The rabbit was very happy and the next day they both went off together to study the animals in the forest. They had lots of fun, and they both learnt a lot.
<|endoftext|>
Once upon a time there was a modest lake in the middle of the forest. All the animals around were waiting to welcome a new visitor.
One day, a little 3 year old girl arrived at the lake. The animals were so excited to see a human for the first time! The squirrel welcomed her with a friendly “hi” and the deer said “hello”. The little girl was so happy to meet the animals and she replied “hi! It’s so nice to meet you!”
The little girl roamed around the lake and animals went with her. She laughed and made so many friends. All the animals were so happy that she came to visit the modest lake.
They spent a lovely day together playing and exploring the lake. In the end, they all said goodbye and the little girl said “Thank you so much for welcoming me! I had so much fun!”. And with that, she waved goodbye and continued her journey.
<|endoftext|>
One day, Jane and her daddy were at the park. Jane saw something very special - a big green tree with green powder around it. Jane walked closer to the tree and saw that the powder was made of tiny green pieces.
"What is that Daddy?" Jane asked.
"That's special powder, Jane," her daddy replied. "Let's gather some of it together and take it home with us."
So Jane and her daddy started gathering the powder into a bucket. They filled the bucket up with the powder and started walking home.
When they got home, Daddy asked Jane what she wanted to do with the green powder.
"Let's make a special cake with it," she said.
So, Jane and her daddy used the green powder to make a special cake. They cut it up and shared it between them. Jane smiled, as it was the yummiest cake she had ever tasted.
The end.
<|endoftext|>
It was a sunny day and Jimmy was out playing in the park. As he ran around, he came across a mouse. He was excited to see it and noticed how flexible the little mouse was.
Jimmy exclaimed, “Wow, that mouse is so flexible! Maybe it wants to be my friend!”
The mouse gave him a little surprise, by hopping right up on his shoulder! Jimmy was overjoyed and thought to himself, “Now I have a new best friend!”
Jimmy and the mouse were having so much fun running around the park together, but then suddenly they heard someone coming towards them. It was Jimmy’s mom. She had come to take him home.
Jimmy shouted, “Mom, look, I made a new friend, a mouse!”
But to Jimmy’s surprise, his mom said, “Oh no, we can’t keep it. Poor thing, let it go.”
Jimmy sadly said goodbye to his new friend, and watched as the mouse ran away. He realized he would never see it again.
The end.
<|endoftext|>
Once, there were two friends who were playing in the yard. One was clumsy and the other wasn't.
The clumsy one said, “Let’s catch a bug!”
But the other one disagreed.
The clumsy friend said, “Why don’t you want to catch a bug?”
The other friend said, “Bugs can be scary. Let’s play hide and seek instead.”
The clumsy one disagreed. “No, let’s catch a bug!”
Then, the two friends had an idea. They decided to play both games. First, they would catch a bug and then after, they would play hide and seek in the yard.
They ran around the yard, chasing the bugs and having lots of fun. The clumsy one ran clumsily and the other one ran quicker and caught more bugs.
The two friends laughed and played together until they were tired. They went home feeling happy and excited.
<|endoftext|>
One day, Little Bear and his Mommy went for a visit. She took him to a place he had never seen before. It was an icy place with lots of snow. As they walked around, Little Bear heard some music. It came from something his Mommy called a radio. It made Little Bear smile.
When Little Bear asked his Mommy about it, she said it was called a radio and that it played music.
Little Bear said, "Can I make music with it too?"
Mommy said, "Yes, Little Bear, you can make your own music too. Let's try it together."
So Little Bear and Mommy made music together with the radio. Little Bear was so happy. It was an amazing visit!
<|endoftext|>
Once upon a time, a little girl named Nora wanted to explore nature. She went to a meadow filled with white flowers, and she picked one that was the prettiest. She smelled it, and it was so sweet.
Then Nora saw a small bunny hopping in the grass. She giggled and smiled, and she softly called the bunny over to her. The bunny hopped closer and closer until it was right beside her. Nora was so happy, so she bent down and kissed the bunny on its nose.
The bunny was very happy, so it hopped off into the meadow and found it's family. Nora smiled and looked out into the meadow, taking in all the whiteness and beauty of nature. It was so gorgeous, like a picture from a fairy tale.
Nora kept playing until the sun started to go down. She thanked nature for this amazing day and kissed her hand and blew it towards the sky. And with that, Nora went home and went to bed, dreaming of all the wonderful things nature had to offer.
<|endoftext|>
Once upon a time, there lived a lively young reindeer in the North pole. He was always so excited about the snow and he loved playing out in the cold! One day, he decided to go off into the snow and explore.
So off he went, exploring the snow and having fun. But suddenly he noticed something he hadn't seen before - a big, deep hole in the snow. He went over to have a look and noticed it was full of ice.
Just then, his mother noticed what was happening and called out to him. She warned him to stay away from the hole and said, "Don't go too close! The ice is too cold for a reindeer like you!"
The young reindeer listened carefully and promised to stay away from the deep and chilly hole. He thanked his mother for her warning and promised to be more careful from then on.
The lively reindeer was much more cautious and kept a safe distance from the deep, icy hole. He kept a smile on his face and continued exploring the snow.
The end.
<|endoftext|>
Once upon a time, there lived a little girl called Lucy. One day, Lucy was feeling very sad. She wanted to fly away so she could be happy but she was too young.
Then, a bright flame appeared in the sky. She was scared at first, but then she saw that the flame was made of magic.
Lucy asked the flame, "Can you let me fly away so I can be happy again?"
The flame answered, "Yes, I can permit you to fly away but first you must promise to take care of your family."
Lucy smiled and said, "I will certainly take care of them. Please let me fly away!"
The flame permitted Lucy to spread her arms and fly away into the night. She felt happy, free and no longer sad. Lucy waved goodbye to the flame and continued with her adventures.
<|endoftext|>
Once upon a time there was a brave warrior who lived far away in the forest.
One day the warrior sailed away to explore the world on a small boat. They sailed around for hours and hours, eventually coming to a new land.
The warrior was curious so they jumped off the boat and started to explore. But it was uncomfortable, so the warrior decided to go back to the boat.
In their hurry to get back, the warrior called out, “Quick! Quick!”. It was then that a friendly bird flew over. The warrior smiled and asked the bird, “Do you know a faster way to sail?”
The bird replied, “Of course! Follow me, I'll show you!” The warrior quickly hopped on the boat and followed the bird.
The bird showed the warrior how to make the boat sail faster and soon the warrior was on their way. The breeze was gentle and the warrior felt comfortable once again.
The warrior thanked the bird for showing them the way and sailed away, never to forget the bird's kindness.
<|endoftext|>
Once upon a time, there lived a little girl. She loved going outside to play in the sun. One day, the sun was shining so brightly and everything was so warm.
The little girl excitedly started to run around. She ran so fast she got dizzy, then fell to the ground.
But then, to her surprise, she felt something cold. She looked down and saw the ground was covered in snow. The little girl gasped.
She quickly ran to her mom and said, "Mommy, there's snow outside! Can we go play?"
Her mom chuckled and said, "Yes, but we have to grab a sack first."
So they went outside and gathered up the snow in a sack. The little girl was so excited that she twirled around and around, making a mini snow storm.
They took the sack home and put it near the fireplace. The little girl wanted to play with the snow all day, and her mom said she could do just that.
So the little girl spent the day playing with the snow until the sack was empty. It was cold but still so much fun!
<|endoftext|>
Once there was a boy named Tom. Tom wanted to see something special, so he went to a high mountain. It was sunny and warm outside so the snow began to melt. Tom found something surprising: a magnet! He was excited and picked it up.
Tom looked around and tried to find something with his magnet. He soon noticed that the magnet was attracting some pieces of metal on the ground. He picked them up and put them in his pocket.
Tom kept playing with his magnet. Suddenly he heard a noise, it was high and loud! He looked up and saw a beautiful rainbow. He smiled, this was something special!
<|endoftext|>
One summer morning, a little boy named Andy was walking around outside. He saw a white rabbit in the grass and wanted to touch it. He walked over to the rabbit and reached out his hand, but he stopped just before he touched it. There were two green spiders crawling on the rabbit. He had never seen anything like this before, and he was scared! He stepped back and thought of a plan. He quietly reached inside his pocket and found some small stones. He threw the stones at the spiders and they ran away! He was so happy, he could touch the rabbit now. But then, the rabbit hopped away. Andy was a bit sad but quickly remembered he still got to touch the white rabbit. It was a special moment.
<|endoftext|>
Once there was a little girl named Lucy. She loved to play with her toys, but today was different. She was outside with her parents and there were a lot of people around. They were all wealthy people and were talking about something strange.
Lucy listened carefully, but the words were all strange to her. She then noticed one wealthy man pointing to his toes. She wondered why and asked her dad, "What's he pointing at?"
Her dad laughed and smiled, "That man is showing off his money! He's wealthy and he wants everyone to know."
This made little Lucy excited. She wished she had money too. She wanted to show off her wealth like the man.
But then her dad said something that made her sad. He said, "It's just playing pretend. You don't need money to have fun!"
So Lucy put away her dreams of being wealthy and went back to playing with her toys. But secretly she still hoped one day she could show off her own wealth too!
<|endoftext|>
Once there was a boy who liked to run. Every day he ran faster and faster. He was so fast that he seemed to float rather than run! One day, his mommy gave him a weight to carry. It was big and heavy, but the boy didn’t mind. He held on tightly and ran with it, as if it were nothing.
He ran for hours and hours, never stopping for a rest. The weight grew heavier and heavier, but the boy never thought about it. He kept on running, ever faster and ever further.
Then, all of a sudden, the boy felt himself trip! He had been so careless, he couldn’t keep his footing. He had been running too fast and too far, with too much weight in his hands. The weight had been too heavy for him, and as he fell, he knew that he had gone much too far. Now it was time to turn around and run back home.
<|endoftext|>
Once upon a time there was a coat frame. It was fit for a special occasion. A little girl named Rachel came to try it on.
Rachel noticed that the frame was disturbed. It was not standing up straight.
"Don't worry," said her mother. "We can fix it."
Her mother carefully adjusted the frame. Rachel stepped in, and it was a good fit.
"It looks beautiful," said her mother. Rachel smiled in delight.
The frame was no longer disturbed. It was standing up straight and Rachel looked wonderful. That's how Rachel got to wear the perfect coat frame for her special day!
<|endoftext|>
Once upon a time, there was a modest car. It drove around the country at a careful speed. Every day, its driver, Lizzie, said to the car, “Let’s go! Let’s speed!” But the car never wanted to go too quickly.
One day, Lizzie spotted a rabbit hopping along the country road. She looked at her car and said, “Oh dear! We need to speed up or we’ll never catch this rabbit!” So, Lizzie put her foot down on the pedal and the car began to go faster.
The rabbit kept hopping along, faster and faster, until it was a tiny blur on the horizon. But the car managed to keep up, going at a modest speed. In the end, Lizzie drove her car all the way to the end of the country road and the rabbit hopped off into the sunset.
<|endoftext|>
One day, Mary was sitting on the grass in the park, eating a sandwich. She chewed it slowly, looking around. Suddenly, something sparkly caught her eye - it was a silver necklace glistening in the sun. Mary noticed it was near a bush, so she crawled over to take a closer look.
When she got close, Mary could see that the necklace was suspended from a thin branch. She reached out to take it in her tiny hand and felt it's cool metal.
Just then, a voice called out from behind her. It was an old woman.
"Do you like it?" she said.
Mary was a bit anxious but nodded and smiled.
"It's yours," the woman said warmly. "I saw you admiring it and thought you might like to have it."
Mary thanked the woman politely, before heading home with the new silver necklace in her pocket. From that day onward, every time Mary chewed her lunch in the park, she would also play with her silver necklace, and think back to the day when she had first seen it.
<|endoftext|>
Once upon a time, there was a little boy named Joe. He was always happy and very healthy.
One day, Joe saw a lovely bird in the sky. He was so amazed and pointed at it.
"Look, look!", he said to his mum.
His mum looked up and smiled. "Joe, don't you realize the sky is filled with so many birds?"
Joe thought for a second, and then his face lit up. He had realized that the sky was full of wonderful birds.
Mum smiled, proud of her little boy. She was glad to see him realize something so special. Joe was happy too - he had just had a wonderful realization.
<|endoftext|>
Once upon a time, a little girl named Lucy was playing with her chalk. She drew beautiful pictures with it outside her house.
Suddenly, her friend Mary came over and asked if she wanted to play. Lucy said yes but Mary thought of something else to do. She wanted to cut her chalk in half.
Lucy was not happy about this. She didn't want anyone to mess with her original chalk. But, Mary kept insisting and said, "C'mon Lucy, let's cut the chalk! It'll be fun!"
Lucy refused but with some convincing from Mary, she agreed to it. So, they got a knife and started cutting the chalk. But, to their surprise, the chalk pieces became smaller and smaller until the chalk disappeared.
Lucy felt sad. She knew that her chalk could never be the same again. Better not to mess with an original.
<|endoftext|>
Once upon a time there lived a little girl named Amy. She was very alert and always looked for new things to explore. One day she decided to search for a painter who could help her. She went out of her house and looked everywhere.
Amy walked along the street and soon she found a painter. She was so excited! She asked the painter, “Can you help me?” The painter smiled at Amy and said, “Yes, I can! What do you need help with?”
Amy said, “Can you paint my bedroom? It would look so much better.”
The painter smiled again and said, “Yes, I can do that for you. I can make it very special.”
Amy was very happy and thanked the painter. She watched as he painted the room. It was as if magic had come to her bedroom.
Amy was especially alert that day when she watched the painter working in her bedroom. She enjoyed every moment of it. When the painter was done, she thanked him again and gave him a big hug. The painter smiled before he left.
Amy's bedroom had never looked so good before. She was so happy and smiled from ear to ear.
The End.
<|endoftext|>
Once upon a time, there was a little girl named Lola. She was three years old and she loved purple things. One day, she was walking in the park when she saw a big pastry. It was covered in purple frosting, and she wanted to try it!
Lola ran to the pastry and pulled at the top. It was stuck, so she pulled harder and harder. Suddenly, the pastry tore in two!
Lola gasped in surprise and said, "I did it!" She grabbed one of the pastry pieces and took a big bite. It tasted so sweet and delicious.
Suddenly, Lola heard her mother's voice and she knew it was time to go home. She quickly picked up the other piece of pastry and ran to her mother.
Lola showed her mom the pastry and said, "Look what I found!" Her mother smiled and said, "It sure looks yummy. Now let's put it in a bag until we get home."
The End
<|endoftext|>
Once upon a time, there was a creative farmer who lived on a farm. He loved his farm and the animals who lived there. Every day he would go out and take care of the animals.
One day, the farmer noticed something strange. One of his ducks seemed to be explaining something to the other animals, but he couldn't understand a word of it.
He went over to the animals, and said, "What is going on here?".
The duck replied, "I'm explaining to the other animals that over the hill, there is a big pond with lots of yummy bugs and fish."
The farmer smiled and said, "That sounds like a wonderful idea. Let's go explore this big pond and see what we can find.”
So, the farmer and the animals marched over the hill and across the field until they reached the big pond. They had lots of fun, playing and exploring around the pond, and found lots of yummy bugs and fish.
The farmer thanked the creative duck for showing them the pond, and all the animals went home happy.
<|endoftext|>
Once upon a time a little girl named Jill had a very special toy. It was a black car that could zip around the room. She loved playing with it, zipping it back and forth. Every morning when Jill woke up, she would go to the toy car to make sure it was still there.
One day, when Jill looked at the car, she noticed something strange. There was a print on the side. She couldn't figure out where it came from. She kept looking at the print and suddenly, the car started to zip across the room. Jill was so excited, she couldn't believe it!
The car kept zip, zip, zipping all around the room. Jill followed it and it stopped at a big black box. Jill opened the box and inside was a present for her. It was a black toy robot! She was so excited and couldn't believe her eyes.
Jill understood that the print on her car was the same as the print on the box. The car had known it was the present all along and had zipped across the room to show her the special surprise.
<|endoftext|>
Once upon a time, there was a small girl named Susie. Susie loved to go exploring in the big backyard of her house. One day, Susie went outside with her teddy bear. As she was running around, she saw something hidden behind a bush. She went near it, and when she peeked behind the bush, she found a kitty! Susie was so excited to see the kitty that she ran over to it.
Susie said to the kitty, "Hi kitty, why are you here all alone?"
The kitty meowed and then said, "I'm lost. I don't know how to get back home."
Susie felt so sorry for the kitty and she wanted to help him. She said, "Don't worry, kitty. I can help you find your way home! Let's go visit and see."
So Susie and the kitty started walking to find the kitty's home. After a while, they ran into some trouble. There was a big angry dog that blocked their way. Susie and the kitty were scared, but Susie kept her head and said, "Don't worry, kitty. We can find another way." So they both ran away and found a hidden path to get to the kitty's home.
Finally, they arrived at the kitty's house. They said goodbye to each
<|endoftext|>
John and Sarah were playing together in their backyard when they found a piece of metal. It was shiny and reflective and they couldn't wait to show their parents.
John asked Sarah, "What should we do with the metal?"
Sarah thought for a moment, then said, "Let's take it to Mommy and Daddy!" With that, they ran off excitedly, ready to surprise their parents.
They raced into the house, and shouted, "Mommy, Daddy! Look what we found!"
Their parents were very surprised and asked, "Where did you find this piece of metal?"
John and Sarah were so proud of their discovery, and couldn't wait to tell the story. They recounted that they found the metal outside in the backyard and it was so shiny and reflective.
Their parents smiled, and said, "Well, why don't you two take it around the neighbourhood and see if you can return it to its rightful owner. If nobody takes it, you two can keep it!".
John and Sarah were so cheerful and excited about the prospect of helping find the true owner of the metal, that they grabbed it and set off, ready to call on their neighbours.
<|endoftext|>
There was a little girl with dark hair. Her name was Joy. She lived in a big house with her parents. One day, Joy was playing outside in her garden. Suddenly, she felt something on her leg - something pinching her. It was a big, black bug!
Joy screamed and tried to get away, but the bug kept following her. She tried to run and hide, but it was too quick.
Joy's parents heard her cries and came running. They used a stick to help her get rid of the bug. After the bug was gone, they hugged Joy and told her everything would be alright.
When the bug was gone, Joy felt relieved and happy. She went back to playing in the garden, making sure she didn't step on any more bugs.
<|endoftext|>
Once upon a time there was a little girl named Rita. She was gentle and sweet and was always nice to everyone. One day Rita was walking in the park and noticed something shiny. She decided to take a closer look. As she got closer, she realized that someone had stolen someone else's toy.
Rita was very sad because she knew the toy belonged to someone else. But then she looked at the toy, she noticed that part of it was broken. She put her small muscle into work and managed to fix it.
Rita picked up the toy and decided to find who it belonged to. She went all around the park, showing the toy to anyone who looked like they were searching for it. Finally, she found a young boy who was looking for the toy.
Rita quietly gave the toy to the boy, who looked at her in surprise. He thanked her and said, "You taught me a very important lesson: to respect people’s belongings and to treat others with kindness."
Rita smiled, feeling proud of herself. She had done something good and made a difference. Later that day, Rita thought to herself, "When you are gentle and kind, you can do magical things!"
<|endoftext|>
One day, John and his mom were out in the woods. John was looking to find some lumber for his toy boat. They had been scourging for hours, but hadn't found anything yet.
"Are you sure there's lumber around here, Mom?" asked John.
"Of course," she said happily. "Just keep looking, I'm sure we'll find it."
John kept searching, but soon stumbled upon an ancient chest. He excitedly opened it, demonstrating his dependable strength. Inside, he found the lumber he was looking for.
John quickly improved his toy boat, since his strength was now dependable. With newfound confidence, John raced off with his boat in the river. He sailed faster than ever, enjoying the adventure he had found.
John sure was glad he found that lumber!
<|endoftext|>
Once upon a time, there was a little boy named Thomas. He was three years old and loved to explore. One day, he went on a big adventure to a far away oasis.
On his way, he found a broken tree branch. He decided to touch it, but quickly pulled his hand away as it was too sharp.
As Thomas continued his journey, he pondered why the branch was so broken. He soon came across a little river that was flowing down the side of the oasis. He remembered the branch and wondered if the river had something to do with it.
The little boy arrived at the oasis and he was in awe. He ran to the edge of the water and started to touch it. As soon as he did, the river started to swell and the current quickly became stronger. Thomas quickly pulled his hand away.
The little boy realized that the branch had broken from the rapidly rising waters. Thomas now understood why the branch was so broken and he was careful not to touch it again.
<|endoftext|>
Once upon a time, there was a lazy figure who was always looking for ways to relax. One day, he saw a big tree in the distance and decided to take a nap. As he was lying there, a small voice shouted, “Hey! Wake up!”
The lazy figure opened his eyes and saw a small child standing in front of him. The child was insisting that the figure should come play with him. But the lazy figure was feeling too lazy to move so he politely declined the friendly offer.
The child was very persistent, though, and he kept insisting that the figure should come play. So the figure finally gave in and agreed to follow the child's lead.
And so, the lazy figure followed the boy and had the most amazing day! They laughed and played for hours and soon their day had come to an end. The figure was very grateful for the company and said goodbye to the wonderful little child.
The figure returned home feeling refreshed and kids all around continued to insist that he join them to have lots of fun.
The end.
<|endoftext|>
Once upon a time there was a new little bunny. Her name was Chloe and she was very excited to explore the world.
One day she was hopping in the forest when something big happened! The trees began to shake and the ground rumbled. Chloe didn't know what to do, so she crouched down and covered her ears until the shaking stopped.
When it was all over, Chloe looked around and saw all of the other animals. They were all looking just as scared as she felt.
Suddenly, a wise old owl spoke up. "My friends," he said. "We just had an earthquake!"
Everyone looked confused. "What is an earthquake?" Chloe asked.
"It is a big shaking that happens sometimes," said the owl. "We all need to be careful when it happens!"
Chloe thanked the owl for teaching her something new and, after that day, she liked to be extra careful whenever she heard rumbling in the ground.
<|endoftext|>
Once upon a time, there was a little girl named Molly. She was very worried, because she had lost her favorite toy. One night, while she was crying in bed, she heard a gentle hooting sound. Molly opened her window and a friendly owl flew in.
Molly was surprised, but the owl only wanted to help. It flew around the room, searching until it found Molly's toy. It bowed its wings and dropped the toy in Molly's lap.
Molly was amazed and asked the owl, “What are you?”
The owl hooted again and said, “I'm an owl! I saw that you were worried so I wanted to come and restore your toy. Now, please have a good night's sleep.”
Molly thanked the owl and fell asleep with a smile on her face. From that day on, Molly was sure that owls were magical creatures who could make any worries go away.
<|endoftext|>
Once upon a time there was a small boy who wanted to go on an adventure. He decided to take a boat out to sea. After a few hours, the boat sailed onto a big, beautiful island.
The island was so nice that the boy wanted to explore it. He jumped out of the boat into the water and started to swim towards the island. There was a mild breeze that kept him cool as he swam.
The boy arrived on the shore of the island. He looked around and noticed a small hut. He stood up and walked towards it. When he arrived, he heard a voice say, "Hello! Who are you?"
The boy was surprised. He looked around and saw an old man standing nearby. The old man said, "I'm the island's caretaker. My name is John. What's your name?"
The boy smiled and said his name. Then he asked if he could explore the island. John said to him, "Of course you can. Just be careful - some of the island can be a bit wild. I'll stay here and make sure you're safe."
So the boy explored the island with John. They walked around the beach and swam in the mild ocean. Then, when it was time to go back, the boy thanked John for showing him the island and waved goodbye.
The boy sailed back to the shore with lots of great memories of the island. He
<|endoftext|>
Once upon a time there was a fairy who lived in a tree near a pond. The fairy was very stubborn and always wanted things to go her way.
One day when the fairy was flying around the tree, she saw a boy who was playing by the pond. The boy had a red balloon which he was dropping into the pond.
The fairy shouted to the boy, "stop, don't drop the balloon!" But the boy was too stubborn to listen and he dropped the balloon into the pond.
The fairy flew down to the pond, and with a wave of her magic wand, the balloon rose up out of the pond, much drier and brighter than before.
The boy was so happy. He hugged the fairy and thanked her for saving his balloon. The fairy smiled and said, "You must be more careful next time and listen to me!"
<|endoftext|>
Once upon a time there was a black record. It was very helpful and it could do great things.
One day, a 3 year old wanted to use the record. The record said, "I can't help you out. You have to be older". The 3 year old was very sad.
Then, an old man showed up. He was very helpful and offered to help find a way to make the record work. He tried to figure out how to make the record work, but no matter how hard he tried, he couldn't make the record work.
The 3 year old was very sad. He asked the old man, "Can you make it work?"
The old man shook his head and said, "I'm sorry, but I can't make it work. I tried everything I could. I'm afraid the record will never work again."
The 3 year old was very sad and never forgot the black record. The 3 year old never saw the old man again.
<|endoftext|>
Once upon a time there was a little girl who loved trips. She woke up one morning and asked her mom, "Can we go on a trip today?" Her Mom smiled and said, "Yes, let's go!"
The little girl got dressed quickly and they went outside. The sun was bright and the sky was a beautiful color.
The mom and the little girl walked to the park and went to the pond. The little girl became very excited and wanted to stir the pond. She grabbed the stick and stirred the water.
The pond became a colorful whirlpool of fun. The little girl was so happy that she danced around with joy. Inside the whirlpool, she found colorful fish, rocks, and some small treasure.
The mom and the little girl had a wonderful trip and returned home with lots of beautiful memories.
<|endoftext|>
Once upon a time, there was a girl named Jane. She was spreading candy around with her friends. Everyone was having so much fun; they couldn't stop laughing.
Suddenly, John came over to the group and saw everyone with the candy. He felt envious that he didn't have any.
Jane happily offered John a piece of candy. "It's okay," she said, "We'll share."
John couldn't believe how kind Jane was. He accepted the candy and enjoyed it together with the other children.
Moral: Sharing brings people closer together and can make everyone happy.
<|endoftext|>
Once upon a time there was a little girl who loved to play. Everywhere she went she would find something new and exciting to play with.
One day the little girl was playing in the garden when she found a strange passport. The passport looked weird and she wondered where it had come from. The passport belonged to a magical mermaid who had been visiting the garden.
The little girl wanted to show the passport to her family, so she put it in her pocket and went inside. But when she went to show her family the passport, there was no sign of it anywhere.
The little girl looked everywhere but there was no sign of the passport. She asked her family if they had seen the passport, but they hadn't seen it. Suddenly, the little girl heard a voice coming from the garden. It was the magical mermaid, who thanked the little girl for finding her passport.
The little girl was so happy to have found the passport and the magical mermaid was grateful to get it back. They played in the garden together until it was time for the mermaid to return home.
From that day forward the little girl was never without her passport, always ready to explore new and exciting places.
<|endoftext|>
Bruce was an incredibly brilliant three year old. He was playing with his friends in the garden and they were having a lot of fun. They were playing a game but Bruce started to feel like something wasn't quite right.
He asked his friend, "Do you trust your sauce?" His friend shrugged and said, "Sure, it's tasty and I always eat it." Bruce thought for a moment, then asked, "Do you think it's always reliable?"
His friend replied, "Yes, it's always been brilliant and hasn't let me down. I think it's reliable." That was enough for Bruce and he decided to trust the sauce.
He made a choice to keep playing the game and have fun, trusting the sauce would always be reliable. Together with his friend, they finished the game happily.
<|endoftext|>
One day, Mom and Jack were in the garden. Jack looked around and saw all the different colors of the flowers. "Mom, can I pick one?" he asked.
Mom nodded. "Yes," she said. "Pick a big, reliable one that won't break when you bring it inside."
Jack thought and thought, then picked a pink one that was very big. He put it in his pocket. But when he got home, he realized the petals had fallen off his flower.
Jack was sad. How could he show Mom something reliable now? He asked his friend Paul for help. Paul said he could help, but first Jack had to do something for him.
Jack said okay, and Paul told him to pick one extra flower from the garden to bring to him. Jack nodded, went back to the garden, and carefully chose a yellow flower.
Jack brought the yellow flower to Paul, who said thanks and gave Jack some seeds from his garden. Jack planted the seeds in his garden, and now every summer Jack can see his reliable flowers growing!
<|endoftext|>
Once there was a little girl called Lucy who wanted to sell something very special. She carefully wrapped up her knee in a box and took it outside.
Once she got to the market place, Lucy could see the many different people gathered together and she felt shy. She began to shout, “I’m selling my knee!”
One of the people at the market was an old woman who had seen many things in her life. She approached Lucy and said, “Do you want some help selling your knee?”
Lucy nodded and smiled. The old woman was very compassionate and kind and she soon found a buyer who was willing to pay a good amount of money for Lucy's knee. Lucy could not believe her luck!
The old woman then said, “You should always be brave and use your compassion when trying to sell something. You never know who might be in the market place and be willing to buy it.”
Lucy smiled and said, “Thank you so much for your advice and for helping me to sell my knee.”
The old woman smiled back at her and said, “It was my pleasure. I'm sure you'll have success in other things you try and sell in the future.”
And Lucy never forgot the old woman's words or the lesson she had learnt on that day.
<|endoftext|>
John watched a bug crawl across the grass. He was careful not to hurt it. His mom smiled as she watched him.
Mom picked up the little bug and put it inside her case. She explained that it would be safer inside.
John was upset. He wanted the bug to stay outside and play. He began to cry.
Mom gave John a hug, and she sighed. She said that she was sorry, but it was safer inside the case.
John smiled. He still missed the little bug, but he understood why mom was being so careful.
John and mom hugged again. Mom thanked John for understanding, and they went on to play some more.
<|endoftext|>
Once there was a boy. His name was Tim. He was three years old and was very adventurous. One day he decided to go for a walk with his parents.
As they walked, they noticed something wonderful. There was a lake, with bright blue waters, and beautiful green trees surrounding it.
The family couldn't help but add it to their list of favorite places.
Tim was so excited, he said, "Can we go explore? I would love to see what's there!"
His parents replied, "Yes Tim! What an adventurous idea!"
They all went to explore. Tim discovered so many amazing things. He found colorful rocks, and new plants he'd never seen before. He even saw some animals stepping out of the water.
Tim added these sights to his memory, and felt a sense of wonder as he explored. He had a great day with his family and enjoyed their adventurous outing.
<|endoftext|>
Once there was a messy lizard. He wanted to move around the garden. He saw a beautiful flower and said to himself, "I can move that way." So the lizard moved towards the flower.
He saw a big tree and said to himself, "I can move that way." So the lizard moved towards the tree.
Suddenly, he heard a voice. It was a ladybug. The ladybug said, "Where are you going?" The lizard said, "I'm moving around the garden."
The ladybug said, "Would you like help?" The lizard said, "Yes please!" So the ladybug and the lizard moved around the garden together.
They found a muddy puddle and the ladybug said, "Let's move that way." So they moved towards the puddle and made a mess. But they had a lot of fun!
<|endoftext|>
Once there was a little girl named Ella. She was the most popular girl in school. She loved to play on the balancing beam in the playground. She was so good at balancing that she never had to use her muscles.
One day, all the kids gathered around Ella, asking her to show them what she could do. She smiled and got on the beam. She balanced so well that the kids all applauded.
Ella's teacher came out and told her not to stay on the beam too long. "Sometimes, muscles get tired," he said.
But Ella didn't listen. She stayed on the beam for a really long time. Eventually, her muscles got tired and she fell off. Everyone was very sad. Ella's teacher told her to be careful next time.
But Ella didn't listen and she fell off the beam the next time too. And the next time. The kids in school stopped asking Ella to balance on the beam, since they were afraid something bad might happen. Ella was no longer the most popular girl at school.
<|endoftext|>
Mama and Papa had a party for their little girl. It was her third birthday. Everyone had come over to celebrate. There was cake, games, and balloons. The little girl was so excited.
The guests all cheered as Mama and Papa gave the little girl a shiny new toy. "Thank you," she said with a smile.
Mama and Papa then revealed to the guests that the toy was actually a surprise. They said it was a trap. The little girl was curious and asked what it was. Papa explained it was like a game. He said if she did something the trap would make a noise and they would all applaud.
The little girl was embarrassed, but she was excited too. She stepped up to the trap and tried her best. When the trap finally made a sound, everyone clapped and cheered. She was so proud of herself.
"See," Papa said, "you were brave and you did it!" The little girl smiled and hugged Papa. She was so happy to have accomplished something and everyone else was proud of her. It was her best birthday yet.
<|endoftext|>
Jack and Sue were playing in the yard when they spotted a Dinosaur. They both ran up to it to take a closer look. Sue was filled with amazement.
"Wow!", she said awely. "Where did it come from?"
"I don't know", Jack said. But let's hang it up in my room so we can look at it everyday."
The two of them grabbed the dinosaur and filled it up in Jack's room. Jack hung it from a tree branch in one corner of his room and it looked very nice.
Sue watched with a proud smile.
"That makes your room look really humble", she said.
Jack smiled happily.
"Thank you Sue!", he said with a big smile. "Now I can see it every morning when I wake up!"
<|endoftext|>
Once upon a time there was a little girl named Emily. She was very excited when she woke up one morning because she was going to have a special surprise.
Emily was told over breakfast to put on her shoes and wait outside. When she opened the front door she saw a tower of spicy food, her favorite!
Emily took a bite and instantly thought it was the best she had ever tasted. She kept eating and eating until the tower was gone!
Soon, Emily started to feel strange. Her belly was getting bigger and bigger and was starting to hurt! Emily's parents tried to make her feel better, but nothing worked.
Finally, Emily had to go to the hospital. The doctors told her she had thought too much spicy food and that she needed to stay in bed for a few days so she could get better.
Emily was really sad and never wanted to eat spicy food again. The end.
<|endoftext|>
Sue and Mike were planning a picnic in the park. They wanted to have the best time ever! Sue and Mike packed snacks for their picnic. They brought lots of different snacks, but their favorite was the beans.
When they arrived in the park, they spread out their blanket and started to get ready for the picnic. Suddenly, Sue noticed something strange – there was a deaf rabbit in the middle of the park.
Sue was excited. She called out to Mike, "Let's give him some beans!" Mike nodded with a smile and together they took out an extra portion of beans and placed it near the rabbit.
The rabbit hopped around the beans and started to eat. Sue and Mike were delighted to see the rabbit enjoying their snack. They had a wonderful picnic and plan to visit the park again soon.
<|endoftext|>
Once upon a time, there was a zipping sound in the quiet room. It sounded like someone was playing with something. Two friends, Mel and June, were curious and excited to find out what was making the noise.
"What's that noise?" asked June.
"I don't know," said Mel, "Let's go find out!"
The two went searching around the room until they found the source of the noise: a pin, zipping up and down the wall!
"How unusual," said June, "How does it zip up and down the wall like that?
Mel put her finger to her lips and said, "Shhh, maybe it's magic?"
June's wide eyes lit up as she said, "That's it! I think we should try to figure out how it works!"
The two friends worked together to try and make the pin zip again. After a few minutes of hard work, the pin began to zip again!
"Woo-hoo!" cried Mel, "We did it! How exciting! I think this pin has a magical zipping power!"
June and Mel enjoyed their newfound discovery and magic pin. From that day forward, the two friends would take turns zipping the pin up and down the wall. It was the quietest, most exciting adventure they ever had.
<|endoftext|>
John went to the market one day with his mom. He saw a beautiful blue kite that he really wanted. His mom told him he couldn't have it, but he wouldn't listen. He was too excited and ran to the kite to grab it.
Suddenly, a tough foot stepped on the kite. John was scared and turned around. There was a big man with a mean look on his face. “Mommy,” John said, scared.
The man said, “I run the market and I won’t provide for any children running around and taking things that don’t belong to them.” John was still scared and backed away slowly.
His mom told the man she was sorry and would pay for the kite. But the man said it was too late and he wanted John to learn a lesson. He told John to never take things that don't belong to him again, and he made John leave the market.
John and his mom had a bad ending that day. He never got the kite and he was reminded to never take things that weren't his.
<|endoftext|>
Once upon a time there was a bird named Max. He loved being able to soar through the sky. One day however, Max felt helpless when his wing was injured. He couldn't fly anymore and he was stuck on the ground.
Max's friends noticed this, so they came over to help. "Don't worry, Max," they said. They set up a nest for him and brought him things to eat.
Max was so happy he began to settle in. He was grateful for his friends' help. He felt safer in his nest and didn't feel so helpless anymore.
One day Max had an idea. He asked his friends, "What if I set up a will? That way, if something happens to me, you can take care of my nest."
Max's friends thought this was a great idea. So Max wrote a will that his friends would follow after he was gone. He was so relieved to have this plan in place.
Max's friends made sure to take care of him and the nest. With their help, Max was able to settle in to his new home peacefully.
<|endoftext|>
Once upon a time, there was a light beetle. He had never been outside and wanted to see the world.
So one day, the beetle crawled out of its box and looked around. Suddenly, he saw a big tree and decided to climb it. He worked up the trunk and made it to the top, but found he was stuck.
"Help!" the beetle cried.
Just then, a bird flew by and heard the beetle's cry.
"What's wrong little beetle?" asked the bird.
The beetle explained what had happened, and the bird laughed.
"My friend, the ant, can help you," said the bird. "Let me take you to her."
The bird took the beetle to the ant, who said she could help. She pulled and tugged, and the beetle worked his way around the branch, until he was finally free.
The beetle thanked the bird and ant, before flying off into the light. He had seen the world and was now ready for a real adventure!
<|endoftext|>
Once upon a time there was a very playful puppy named Jack. Jack loved printing, which meant that he could make lots of paper with colourful patterns.
One day, Jack found a small pill on the floor. He was fascinated by the shiny round shape, so he picked it up and tried to print it.
"What are you trying to do, Jack?" asked his mother, who had just seen him.
"I am trying to print the pill, mum," answered Jack.
"Oh, the pill is too small to print. Let's find something else that is bigger and easier to print," said his mother.
So, Jack and his mother went outside and found a big red leaf which they printed. Jack was very happy! The printed leaf was very colourful and beautiful. From then on, Jack kept printing lots of colourful things.
<|endoftext|>
Once upon a time, there was a pale gem which nobody knew the power of. One day a teacher appeared in the village and told the people, "I know the power of the pale gem! I will teach you how to use it." Everyone was excited and gathered around the teacher.
The teacher said, "Now, I will teach you how to make the pale gem magical. First you must find a special vessel and fill it with water. Then place the pale gem in the vessel and watch as it glows." Everyone was amazed!
The teacher continued, "While holding the vessel with the pale gem in it, you must say a very special spell. Say the words 'Pale Gem, I call on you to bring us luck and fortune!' and the gem will become magical and bring us luck and fortune."
Everyone was thrilled and thanked the teacher. The village was now filled with more luck and fortune than ever before, all thanks to the teacher who taught them all how to use the pale gem.
<|endoftext|>
Once upon a time there was a bridge. It was very smooth. All the animals wanted to walk on top of it.
One day a little mouse was walking across the bridge. He saw a big dog on the other side and the little mouse wanted to show the dog how brave he was. He bowed to the big dog and kept walking.
The big dog didn't like the little mouse and he chased him to the other side. The little mouse was so scared and screamed for help. Unfortunately no-one was around to help him.
The big dog finally caught up with the little mouse and he was so angry. He barked very loudly and the little mouse screamed and ran away as fast as he could.
But it was too late. The big dog had been too fast and the little mouse was never seen again.
<|endoftext|>
Once there was a boy who lived in a very beautiful landscape. He loved exploring the landscape and learning about all of the amazing things it had to offer.
One day, while exploring the landscape, the boy came upon a very bossy chipmunk. The chipmunk wanted the boy to do whatever it said and do it right away.
The boy understood that the chipmunk was bossy, so he didn’t argue. Instead, he listened and did as the chipmunk asked.
The chipmunk told the boy to follow it through the landscape. As they walked, the chipmunk stopped at certain places. It was at these places that the chipmunk revealed something truly incredible.
At the end of their journey, the boy finally understood why the chipmunk had been so bossy. It had led him to the most amazing places in the landscape and showed him things he never would have seen on his own.
<|endoftext|>
Once upon a time, there was a boy named John. He was three years old and he was excited for his new birthday. He hoped he would get a special present.
John's mummy took him to the park where all of his friends were. His friends were cheering and they had a big, delicious looking cake. John was very happy and everyone began to sing happy birthday.
John looked around and saw lots of presents sitting next to the cake. He looked at his mummy and said: "Which one is for me mummy?" His mummy laughed and said: "Let's have a look and find out!"
John was so excited to open the biggest present first. He opened it and inside was a comfortable chair. He was so happy and he hugged his mummy. "It's my special present mummy, thank you!"
John sat down in the chair and looked at the cake. He wanted to eat it and hope that it was as tasty as it looked. His mummy cut the cake and everyone had a piece. John took a big bite and he said: "Mummy this is the best cake I have ever tasted!". His mummy smiled and said: "I am so glad you like it".
John was so happy he laughed and clapped his hands. It was the best birthday ever!
<|endoftext|>
Mummy and Timmy were in the closet, looking for something. Mummy asked Timmy to pass her a hanger. Timmy refused because he wanted to pick it himself. Mummy told him that she needed the hanger, but Timmy shook his head and said no. He was being very rude.
Mummy was getting angry now. She told Timmy, "If you don't give me the hanger, you won't get any ice cream." Timmy still refused and said he wanted to pick it himself. He stomped his feet on the floor.
Mummy scolded Timmy and said, "That's not nice behaviour. You have to be polite. Give me the hanger please." Timmy looked at Mummy and said, "Okay." He reached up to the shelf, grabbed the hanger, and handed it to Mummy. Mummy smiled and gave Timmy a hug. "Thank you, my love."
<|endoftext|>
Once there was a little girl named Amy who loved to skip. She could skip from the flower bed to the mailbox, the sidewalk to the trees. Every time she skipped she looked so happy that everyone in the neighbourhood just couldn't help but smile.
One day Amy's dad asked her to come into his workshop. He wanted to show her something special. He pointed to an old box with an original knob on the front. He said, “Amy, can you open this box? It might be filled with something magical.”
Amy was so excited! She tried to turn the knob but it was so tight she just couldn't do it. She asked her Dad, “Can you help me open the box, Daddy?”
Her Dad smiled and gave the knob a big twist. When he opened the box, Amy saw there were lots of ribbons inside. She let out a cheer and said, “I can use them to skip!”
So, with her ribbons in hand, Amy skipped her way around the neighbourhood. Everywhere she went, she put a smile on everyone's faces. The original knob had opened a box of joy!
<|endoftext|>
Once upon a time, there was a very selfish boy who loved to scare his friends. One day, he brought a gas mask to school and he wanted to scare everyone. He even put on the gas mask himself and then tried to scare his friends.
His friends were scared and became angry. One of them said, "Why are you so selfish?"
The boy realized that it wasn't nice to scare his friends. He told them, "I'm sorry. I won't do this again."
His friends were happy and then all of them played together in the playground. They all had a lot of fun and the boy now knows better than to scare his friends.
<|endoftext|>
Once upon a time, there lived an orange tree. All the oranges on the tree were delicious and juicy. The tree wanted to share its delicious oranges with the world. One day, it decided to give away all of its oranges to the local animals.
The animal friends were delighted! The squirrels, birds, rabbits, and more all shared the oranges. They each had as much as they wanted to eat. But the tree remained sad, for it no longer had any oranges left to share.
Just then, the sun began to shine brighter and the sun’s warmth brought new life to the tree. Its branches were soon filled with many delicious oranges.
This time, the tree decided to be more careful. It only gave away five oranges each day and kept the rest. This made it happy and it could remain generous without becoming empty.
The moral of this story is that if we are generous, we can remain happy and still have a lot to give.
<|endoftext|>
Once upon a time, there was a pirate who lived in a far away land. He was a mean pirate and was very intelligent. He looked for ways to steal from others.
One day, he noticed two young kids playing nearby. The pirate decided to steal their toys. He waited until the kids were not looking and then he quickly grabbed the toys and ran away.
The kids were very sad. But one of them, who was very intelligent, decided to take action. He looked around for the pirate and soon spotted him far away in the distance.
The intelligent kid thought of a plan and quickly ran back to get help. He gathered his friends and they all ran after the pirate.
But the pirate knew that they were following him and he was too fast for them. In the end, the pirate was able to escape with the kids' toys and never got caught. The kids were very sad that they couldn't get back what he had stolen.
<|endoftext|>
It was time for the lecture to begin. Little Tom was excited to come to the high school and learn something new. When he arrived, he was amazed at the big space filled with many people.
The teacher started his lecture. He spoke with a voice that was calming and wise. Tom listened carefully and learned many new things. He began to feel a strange feeling in his heart.
Tom asked the teacher, "What is this feeling inside my heart?"
The teacher smiled and said to him, "It's the feeling of healing. When you learn something new, your heart can heal and grow stronger."
Tom smiled and felt happy. He knew that the lecture would help him to heal and feel better. He thanked the teacher for his wise words and ran off to tell the other children the good news.
<|endoftext|>
Once there was a poor little girl named Mary. Mary loved to kick around circles in the dirt. One day, Mary went to the park, kicked the circles around for a while, and got very tired. She decided to take a nap.
While Mary was sleeping, a beautiful fairy flew down from the sky and she said, "What a beautiful little girl! Here, I will give you a special present." She waved her magic wand and a big circle appeared.
Mary woke up, saw the big circle and asked, "What is this?"
The fairy said, "It's a magic circle. It will give you whatever you want. All you have to do is to kick the circle three times, and something special will happen."
So Mary kicked the big circle three times, closed her eyes and when she opened them again, she was filled with joy! The magic circle had given her a bag of money, a beautiful house and a pet dog.
Mary looked up to the sky and thanked the fairy from the bottom of her heart. Now Mary was no longer poor, and she could enjoy kicking circles in the park for hours and hours!
<|endoftext|>
Once there was a family of bear bears. Everyone was very happy and they had lots of fun together.
One day, the family was getting ready to go to a party. They wanted to make sure they looked nice and had the best welcome. So they all worked together to prepare, and it was a tough job.
Finally, the day arrived and the family set out for the party. When they got there, everything was not as they had expected. There was a sign at the door that said "No bear bears allowed."
The family members were very sad and disappointed. They were so surprised that they all just sat there, without saying a word.
Suddenly, the father bear bear spoke. He said, "This is a tough lesson, but the best thing to do is to move on. We should remember that no matter how hard we prepare, not everyone will welcome us."
And with this, the family sadly walked away. They had learned a valuable lesson that day: no matter how much we try to be welcomed, some people will never accept us.
<|endoftext|>
Once upon a time, the ground was dry and hard. Granny was getting ready to go to the market to buy food. Little Jack asked, “Can I come with you, Granny?” Granny replied, “Yes, it’s a lovely day. Let’s go.”
They soon arrived at the market, and Granny bought a lot of food. She told Jack, “Let’s take this food home and bury it in the ground. We can save it for later.”
Little Jack asked, “Why?” Granny said, “So that it won’t get eaten.” Little Jack helped Granny to bury the food and soon enough, the ground was full of yummy food.
The next day, Granny and Little Jack went back to their garden and Little Jack started digging. To his surprise, the food he buried yesterday was still there! Granny said, “Look, Jack, our plan was successful!” Little Jack smiled with happiness. They enjoyed their yummy food and lived happily ever after.
<|endoftext|>
Once upon a time there were two friends named Fluffy and Daisy. They were very playful and loved to watch the world together.
One day, they decided to go on an adventure. They walked around the meadow and watched the birds as they chirped and flew through the sky.
The friends stopped to admire a nearby pond, where they saw a patient old turtle watching them. Daisy, the more playful of the two, was determined to say hello. She waddled up to the turtle and said “Hello, are you watching too?”.
The turtle smiled and quietly replied “Yes, I always watch the world around me”.
Fluffy and Daisy and the turtle enjoyed watching the world for a while together. When it was time for them to go, Daisy waved goodbye, and the two friends continued their journey!
<|endoftext|>
Once upon a time, there was a little girl called Anna. She was three years old and very curious. She wanted to explore the world around her.
One day, Anna was walking through the forest when she came across an old oak tree. She stopped to look at it and noticed that the base of the tree was empty. Anna decided to take a closer look and curiously stepped inside.
She was amazed to discover that the hollow tree was filled with twinkling lights which displayed colourful images. She gasped in delight and called out to her mum, who had been walking just behind Anna.
"Mummy! Come and look!" Anna exclaimed, stretching her arm out to point to the beautiful display.
Mummy smiled, "Oh Anna, you have found a magical tree!"
<|endoftext|>
Once upon a time there was an orange needle called Frank. He had been in the same spot for years and he was getting bored. He wanted to explore, but he didn't know how to.
Then one day, a small 3 year old child saw Frank. The child said "Hello Frank! I'm going to help you explore the world." Frank was so excited!
The child said, "I think we should reverse!" Frank looked confused, but the child explained that it meant going backwards, the opposite of forwards.
So, the child and Frank started reversing. They went up and down, side to side and around in circles. Frank was enjoying his adventure!
After an hour of reversing, the child and Frank stopped. The child said, "Wow, that was a lot of fun! You now know that you can explore by reversing."
Frank thanked the child for his help and then said goodbye. As the child walked away, Frank knew that he would never forget this adventure.
<|endoftext|>
The little girl was standing on the side of the road, watching all the people and bright flags in the parade. She was so excited and wanted to join in. Suddenly, she saw a group of children in the parade wearing cool hats, dancing and singing.
"I want to join!" the little girl shouted happily.
One of the adults in the parade saw the little girl and gave her a big smile. "Come on" he said, diving into the parade, "Come join the fun!"
The little girl followed him and started to dance with the other children. Everyone was laughing and having a great time.
But soon the little girl became frustrated. She couldn't keep up with the other children, and they were all having more fun than her. But then one of the adults came over and said:
"Come on, let's show them how to dive in this parade."
With a big smile, the little girl followed the adult and started to dance and sing. Soon, she was singing and dancing just like the other children, and everyone was having a great time. The little girl was happy and no longer frustrated.
<|endoftext|>
Once upon a time there was a little boy who loved to explore. He wanted to see all the wonders of the world.
So one day he walked and walked until he came to the edge of a huge forest. He was excited to explore the forest.
He ventured in. Soon enough, he came across an extraordinary sight. A giant tree that had a swing that went way up high, so high he could touch the sky. He was so excited he just had to give it a try. So he climbed up the tree and squeezed himself onto the swing seat.
He started swinging and swaying and before long he was feeling so merry and carefree. Suddenly, he felt a massive hand squeeze him tight. He looked around and saw an old and miserable giant. The giant spoke in a grumbling voice, "You don't belong in my forest, get away!"
The little boy was scared and quickly jumped down from the swing. He was so sad, he had to leave the wonderful adventure he had been having. He quietly went home, feeling more than a little miserable.
<|endoftext|>
Once upon a time, there were two friends named Jack and Jill. Jack and Jill loved to match. Every day, they would match rocks, leaves, and sticks. One day, Jack and Jill wanted to match in the harbor.
Getting to the harbor was a long journey, but they kept on walking until they arrived. When they got to the harbor, it was so miserable. There were no rocks, leaves, or sticks to match. Jack and Jill were so sad.
Suddenly, they spotted a pile of match boxes near the harbor. Jack and Jill were so excited, they grabbed one of the match boxes and began to match the colorful boxes. They played at the harbor all day, matching the pretty match boxes until the sun started to go down.
That day, Jack and Jill had an amazing time and each went home with a smile. And they promised to come back to the harbor soon and match again.
<|endoftext|>
Once upon a time there were two friends, Jack and Jill. They were playing together in a big field.
Suddenly, Jack noticed a deep well! He was so excited, he wanted to jump right into it.
But Jill called out, "No, Jack! Don't jump!"
Jack ignored her and he went nearer and nearer. Jill got worried and she said, "Jack stop! I'm scared!"
Jack didn't listen and he was about to jump in. Jill got very scared, so she shouted, "No Jack! Panic!"
Jack was so sorry, he jumped back and started crying. Jill hugged him tight and said, "It's ok, Jack. Don't worry. I'm sorry I scared you."
Jack smiled and they hugged each other. They never came near the well again.
The end.
<|endoftext|>
Once upon a time there was a white phone. The phone was special and could fold out. One day, a little girl, who was three years old, saw the phone and said "Wow!"
The girl wanted to play with the phone, so she carefully folded out the phone. She thought the phone looked like a butterfly. She was very excited and started to giggle.
The girl's mother saw her playing with the phone and said, "No, you must be gentle with it. Folding the phone out is a special thing you can only do when you get older."
The little girl understood and started to fold the phone back together. When she finished folding it, she said "Wow!" again. Then she put the phone carefully back on the table.
The end.
<|endoftext|>
Once there was a strong stone. It wanted to stay by itself so it could be alone. But that was hard to do in the forest. Every day an animal would come by and try to move the stone. But the stone was strong and wouldn't budge.
Then one day, a butterfly flew by and asked the stone why it wanted to stay by itself. The butterfly said it would like to be friends with the stone. The stone was very happy.
The butterfly and the stone became great friends. Every day, the butterfly would come to visit and stay with the stone. The stone was so glad that it didn't have to be alone any more. It was strong and would stay with its friend forever.
<|endoftext|>
Mummy was with her little girl in the park. The little girl loved to play on the swings and they had been there a long time.
Mummy said, "We should go soon. It's getting dark."
But the little girl protested, "No, I want to stay here!" She was having so much fun.
Mummy sighed. She urged the little girl to leave, but the little girl's feelings were too strong.
Mummy was starting to worry. She was worried about the darkness, and that the little girl might get tired and weak. She said, "Come on sweetheart, we must go now."
The little girl felt a bit weak, so finally she agreed to go. Mummy was happy, because she was no longer worried.
<|endoftext|>
A mummy and her little girl called Sarah were getting ready to go on a trip. Sarah watched as her mummy packed a big sack with lots of things.
"What's in that sack, Mummy?" asked Sarah.
Mummy replied, "It's full of lots of fun things that we can take with us on our trip."
Sarah asked, "Can I take my dolly?"
Mummy replied, "Yes of course, but you will have to pack it into the sack yourself."
Sarah was excited and put her dolly safely into the big sack. She looked up at her mummy and smiled.
On the trip, Sarah met lots of friendly people and things she had not seen before. She was having a wonderful time.
When it was time to go home, Sarah remembered that she had put her dolly in the sack and so she checked to make sure it was still there. It was!
Mummy said to her, "Isn't it nice when things are packed up neatly and safely?"
Sarah nodded and smiled.
The moral of the story is to be careful to always pack up things neatly and safely, which helps us to take care of our possessions.
<|endoftext|>
Once there was a mother and her three year old daughter, Molly.
Molly really wanted to sleep in her own bed but her mom said it was still too soon.
Molly remembered that when she was even littler, she used to sleep in a crib.
Molly said, "Mommy, can I sleep in my crib please? It's so little, I think I can fit!"
But mom said no, it was too little and she was too old.
Molly was so sad and asked, "Why can't I sleep in my crib? It's so cozy and fun!"
Mom said, "It's too small, Molly. You're getting so big that you need a big bed now. Come on, I'll have a fun time picking out a big bed with you!"
Molly smiled. She wasn't sure why her crib couldn't be her bed anymore, but it was funny to think of sleeping in a big bed!
<|endoftext|>
Once upon a time there was a kid named Danny. He was playing all alone, but he was not scared.
Suddenly, he saw a big bug. Danny felt fearful and he backed away slowly.
"What do you want?" he asked the bug.
The bug answered, "I want to take a trip on your lip." Danny was surprised, but he agreed. He kissed the bug and closed his eyes.
The bug flew away and Danny finished his journey. Suddenly, he heard a noise—it was the bug coming back.
The bug said, "Thank you for the ride. Now I have to go back to my home. Goodbye."
Danny waved goodbye, and he suddenly realized why the bug wanted to ride on his lip. The bug needed to get back to its family. Danny felt happy and relieved.
<|endoftext|>
Once upon a time there was a crab named Bob. He lived in a big rock by the sea. One day, Bob was walking along the beach and he saw a little girl playing. The girl looked very happy, so Bob decided to greet her.
Bob said, "Hello!"
The girl smiled and said, "Hi there!"
Bob asked, "What are you doing?"
The girl said, "I'm looking for seashells. They are so pretty, and sweet too!"
Then Bob said, "I know of a place that has lots of seashells, right near my rock home. Would you like to come and see?"
The girl was very excited, so she said, "Yes please!"
So Bob and the girl went to Bob's rock home. Sure enough, the beach was full of pretty and sweet seashells. The girl picked up all the shells she could see and thanked Bob for finding them.
Bob said, "You're welcome! I'm glad you're happy."
The girl smiled and gave Bob a big hug.
They said goodbye and the girl ran off, clutching her shell collection close to her heart. Bob watched her go, feeling a great sense of joy. He was glad he could help make someone so happy.
<|endoftext|>
It was a sunny morning and a little girl was taking a walk with her puppy. Her puppy was very excited and pulled at the leash, but the girl was very gentle with him. Suddenly, they heard something and the puppy jumped, making the girl so clumsy that she dropped the leash.
"Oh no!" She said.
The puppy ran off, so the girl started running after him. She ran around the whole park, but she could not find him anywhere. She was about to cry when she finally saw him behind a bush. He was busy cleaning himself.
The girl was so relieved and ran to him. She hugged him tightly and said, "Please don't run away again. I was so scared!"
The puppy looked at her with his big eyes and gave her a big kiss. From then on, she never let go of his leash.
<|endoftext|>
Once there was a bear who loved spicy food. He always used to pick the spiciest of all the food in the village. One day, he was making his usual rounds at the village market when he saw his friend, the rabbit. The bear waved and the rabbit bowed in response.
The bear asked the rabbit what he had in his basket and the rabbit replied, "I'm bringing yummy carrot cake to my grandmother. It's her favourite."
The bear immediately started drooling. He asked the rabbit if he could have some and the rabbit said, "Sure, but it's really spicy. Are you sure you can take such a pain?"
The bear was too excited to wait. He eagerly took the carrot cake and bit into it. Alas! The bear had never tasted such a spicy food before. Suddenly his mouth was on fire and he yelped in pain.
The bear learnt a lesson that day: when it comes to food, not everything that tastes fancy is necessarily best for you.
<|endoftext|>
Once upon a time, there was a brave turtle. She was very small, but full of courage. One day, she decided to explore the big world and find new things.
She started to crawl very slowly. After a while, she saw a small hole under the ground. She wondered what she will find there. She got very excited and started to crawl into the hole.
Once she got in she saw the most amazing thing: thousands of brightly coloured stones and sparkly crystals! She was so excited that she couldn't move.
Suddenly, a small mouse said: "Why hello there little turtle! What are you doing here?". The turtle was so surprised, but she answered: "I'm looking for amazing things!". The mouse smiled: "Well, look no further. You're in the most amazing place!".
The turtle smiled and started to play with the stones and crystals. She forgot about the time, until it got dark and she decided to crawl back home.
The turtle was very happy. She found an amazing place she never knew existed before. Whenever she felt sad, she remembered that magical place she'd seen and smiled.
<|endoftext|>
Once upon a time there was a fat penny. She looked so shiny and beautiful that she made a young boy smile. The boy picked up the penny and decided to take it home with him.
When he arrived home, the boy's mother said, "You can't keep the penny, it doesn't belong to us. You have to return it."
The boy wasn't too happy about that but he had no choice. He slowly walked back to the place where he had found the penny and put it back on the ground.
Suddenly, a fat rat jumped out of nowhere and snatched the penny away. The boy was so surprised that he forgot to chase after the rat.
The boy never saw his penny again. He was very sad.
<|endoftext|>
It was a warm summer day when Billy and his dog, Spot, went for a walk. They continued down the path, hand in hand. As they walked, the waist high grass swayed in the breeze.
Suddenly, Spot spied something shiny in the grass and scrambled to get it. Billy tugged on the leash, but Spot was too excited. Then Billy heard it, a loud 'Slam'. Spot had shut the gate behind him!
Billy dropped the leash and ran to the gate, but it was too late. Spot was nowhere to be seen. Billy was confused. He didn't know what to do.
Luckily, a friendly farmer saw the commotion and helped Billy open the gate. Spot was reunited with Billy and they continued on their walk, hand in hand.
<|endoftext|>
Once upon a time, there was a little boy called Jack. Jack was three years old. He wanted to go out and have some fun.
Every day, Jack's parents would take him to the playground. It was a great place to play. Jack loved ringing the bell and playing with the swings and slides.
One day, Jack heard a strange noise. It sounded like a bell ringing. He looked around and saw a big, red telephone box. Inside was a telephone and it was ringing.
Jack went to his dad and asked, "What is that?"
His dad said, "It's a telephone. Come and rub the buttons. It makes a great sound!"
So, Jack went to the telephone and rubbed the buttons. He was so excited to hear it ring and he kept rubbing the buttons.
The little boy was so happy and he smiled from ear to ear. He said, "This is great!"
<|endoftext|>
Once upon a time, there was a little girl named Jane. She was three years old and she was very curious. One day, she asked her mom if she could have some shrimp for dinner. Her mom said no, because it was too expensive. Jane got angry and demanded shrimp. Her mom said no again and Jane started to cry.
Just then, Jane noticed something pink out of the corner of her eye. It was a magical box with a big, pink shrimp inside. Jane wanted the shrimp more than ever and she demanded it. Her mom was hesitant but she finally agreed that Jane could have it.
Jane was so excited! She clapped her hands and laughed. She thanked her mom, grabbed the pink shrimp and ran outside to play. She was so happy to have a special treat. Jane's mom smiled and felt relieved that Jane was content.
<|endoftext|>
Once upon a time, there lived a girl. She was just three years old and very tidy. Every day, she would clean up her room and make sure everything was in its place. One day, she was cleaning her room when she saw something shiny. She picked it up and saw it was a penny!
She was so excited. She wanted to show it to her mom. She shouted: "Mom! Look!"
Her mom came in. The girl showed her the penny. Her mom smiled and said, "Wow! What a tidy penny. You can keep it safe in your room."
The girl nodded, and put the penny in her drawer. Then, she shut the drawer tightly.
The girl was so happy that she had a shiny penny. She hugged it and thanked her mom for letting her keep it. From then on, she kept her room very tidy so she could keep her penny safe.
<|endoftext|>
Once there was a lady who had a special leg. It was deaf and she never wanted to talk about it.
One day, a little boy asked the lady why her leg was so special. She was surprised he noticed!
The lady smiled and told the boy she was deaf in the leg because she was born that way.
The boy was surprised— he thought it was unusual but very cool! He asked the lady to teach him sign language and she gladly agreed!
The lady taught the boy many things, including how to communicate with people who can’t hear.
From then on, the little boy and the lady shared a special bond— they both knew that being different could be a wonderful thing.
<|endoftext|>
John was walking outside on a warm summer day. He was laughing and feeling happy. Suddenly, he saw a small pile of ash on the ground. He smiled and decided to explore what it was. He bent down and opened the pile of ash. Inside, he saw a little bird. It was still alive, but barely. John smiled and ran to find help for the bird.
He called to a man walking by and asked for help. The man said "No, I don't care. Leave it alone and get away from it." John said "Please help the bird. It needs my help."
The man replied, "No, it's not worth my time. Leave it and go away!" John sadly looked at the bird. He wished he could help it. He smiled and went away.
The little bird died soon after, alone in the pile of ash with no help. John looked back and smiled sadly. He knew that he should have kept trying harder to help.
<|endoftext|>
Once upon a time there was a little girl who was so very careful. One day she went outside to play and she found a caterpillar! She was so excited!
The girl carefully put the caterpillar in her pocket so she could take him home. She stopped and said to the caterpillar, "Let's go home," and the caterpillar smiled.
When they arrived, she put the caterpillar in her garden and said, "You can stay here and have lots of adventures." The caterpillar nodded.
The girl gave the caterpillar a hug and said, "Be careful and remember to stay safe." She watched as the caterpillar crawled away, feeling sure he would have a wonderful time in her garden.
<|endoftext|>
Once upon a time there was a kid named Todd. He was three years old and loved adventure. One day, he decided to sail out to sea on a homemade raft.
Todd hoisted up the sail and it bellowed in the wind. He was scared at first but then he smiled with delight. The sun was shining, the water was glimmering, and he felt like he was on top of the world.
He said loudly to the sea, "This is the best day of my life!"
Suddenly, a giant fish jumped out of the water. "Wow!" Todd called. "It looks like it's trying to play with me."
The fish kept jumping in the air and making loud noises. He jumped and laughed until he was so tired he could barely keep his eyes open. Todd waved goodbye to the giant fish and sailed back to shore.
He thought to himself, "I can't wait for the next time I can sail."
<|endoftext|>
Once upon a time, there was a dependable monkey named James who lived in the woods. He went out every day looking for food and play. All the animals in the forest respected him and always followed his lead.
One day James heard a strange noise coming from the top of the tallest tree. He asked his friends what it was and they told him it sounded like a x-ray machine. James wanted to find out what it was, so he started climbing up the tree.
When he got to the top of the tree, James saw a man was spraying a weird powder all around. The man noticed James and said "Hey kid, don't you never spray anything without thinking first. It could be dangerous".
James understood the message and thanked the man for his advice. From then on James was more thoughtful when it came to taking risks. He remembered that being dependable is the most important thing to be.
The moral of the story is to always be careful when taking risks and to trust yourself when it comes to making decisions. Always remember to be dependable!
<|endoftext|>
Once upon a time there were two friends, Jack and Jill. They were walking in the woods when they saw a turkey.
“Let’s get the turkey!" said Jack.
Jill was scared so she said, “No. That turkey is too fast. We won’t be able to get it."
Jack didn’t give up and said, “I can get the turkey if I run fast."
Jack ran fast, but the turkey ran faster. Then something amazing happened. Jack received help from a friendly animal! The animal ran after the turkey and caught it.
Jack was very happy and said, “Thank you for helping me get the turkey.”
The animal smiled and said, “You’re welcome. Now you can enjoy the turkey. Have a good day!”
Jack and Jill received the turkey and ran home. They had a wonderful dinner that day and were very happy.
<|endoftext|>
Once upon a time there was a brilliant engine who lived in a car. One day, the car drove to a special place with a lot of cars. The engine met many other engines. They all said hello and introduced themselves.
One engine was especially friendly. His name was Alfie and he was just like the others but he was even more brilliant. The engine was so excited to meet Alfie.
The engine said to Alfie, “ Hi, I’m the engine. I’m so glad to meet you!”
Alfie smiled and said, “Glad to meet you too! Let’s be friends.”
So, the engine and Alfie became the best of friends. From then on, the engine was never alone and was always happy.
<|endoftext|>
Sam was a curious little three-year-old, who loved going on adventures. One day, while walking outside, he noticed a big, gloomy looking door. A chill ran down his spine, but his curiosity was stronger. He tip-toed closer, and peeked inside.
Suddenly, he saw something strange. It was big and white, and had funny long arms and strange long fingers. Sam was a bit scared, until it spoke.
"Don't be afraid," said the skeleton. "My name is Skeleton. I live in this dark, gloomy room, and I'm looking for a friend to play with - someone like you!"
Sam was so excited. "I'll be your friend," he said, shouting and jumping up and down. He couldn't believe he was playing with a skeleton.
Since then, Sam and Skeleton have been the best of friends. They play every day, and Sam tells him about all his adventures outside. Skeleton loves hearing about them, and since then, his room isn't so gloomy anymore.
<|endoftext|>
Bob needed to go the bathroom. He ran down the hallway and into the bathroom. It was really hot in the bathroom; the sun was beating down on the windows. It made Bob feel warm and uncomfortable.
Bob went over to the faucet and tried to turn it on. But the water wouldn't come out. Bob knew that something was wrong with it, so he called for his mom.
"Mom! The water won't come out! What should I do?" he said.
"It needs to be improved," said his mom. "It looks like it's broken."
Bob was disappointed. He didn't like the idea of having no water in the bathroom. He knew that it wouldn't be fixed until his mom paid someone to fix it.
So Bob had to find another way to solve his problem. He looked around but there wasn't anything else he could use. Bob was upset, but there was nothing else he could do. He hoped that the bathroom would get better soon, but it looked like he would have to wait.
<|endoftext|>
Once upon a time, there was a brave prince. He loved to learn swordfighting. Every day he would go practice with his teacher.
One day his teacher said he was ready to learn the secret of the sword. The prince watched carefully as the teacher taught him. He learned quickly and the teacher was impressed.
As the prince was leaving, the teacher said, "Remember to share the secret with no one!" The prince promised he would not.
The prince practiced with his sword every day. Everyone was amazed how fast he was learning and how good he was getting.
The prince's friends became envious of him and wanted to learn the secret too. But the prince kept his promise and did not teach them.
The prince kept improving and his friends kept coming back asking him to teach them. But the prince just smiled and kept practicing.
<|endoftext|>
Paul was feeling very happy. Today he was meeting his old friends from his childhood. Paul was excited to see them again as it had been a long time. When he arrived, he was reminded of all the fun they used to have together.
Paul said, "Do you remember when we used to play together in this park? It was so much fun!" All of his friends nodded and started laughing.
His friends suggested they should keep in touch, so they decided to create a network. This way, they could always stay in touch, no matter where they were in the world. They wanted to make sure that their network was reliable so they exchanged emails, telephone numbers and addresses.
Paul was delighted. "This is a great idea! Now, we always have a way to stay connected". His friends agreed and all of them hugged before saying goodbye. Paul couldn't believe how lucky he was. He was reminded of how wonderful it was to have such reliable friends.
<|endoftext|>
Mia was walking in the forest. She heard something that made her stop and listen. Was it a bird chirping? No, it sounded like whistling. She looked around and saw a strange man. He was holding a spear and looking very sad.
Mia ran up to him. "Hello!" she said.
The man jumped and looked up. "Oh! I'm so sorry," he said. "I was just walking and the sun was so warm and I was feeling so lonely that I started to whistle."
"It's OK," said Mia. "I like to whistle too. Will you be my friend?"
The man smiled. "Yes I would love to be your friend," he said.
Mia and the man were now best friends. They enjoyed walking in the forest and whistling together. Whenever the man felt sad, Mia would hug him and say, "It's OK. Everything will be alright."
The man was so happy to have such a wonderful friend. He knew he would never feel alone again.
<|endoftext|>
John was in the park with his Mom. He loved the park and he was always looking out for animals. Suddenly, he saw something in the distance - it was a big, green dinosaur! John was so excited so he couldn't help running towards it.
John's Mom yelled after him and warned him to stop. She said to John, "The dinosaur is not available John. You cannot go near it."
John stopped and looked at the dinosaur. He couldn't believe that a real, living dinosaur was right in front of him. He wanted to get closer but he listened to his Mom and stayed where he was.
John waved goodbye to the dinosaur as he and his Mom left the park. John was happy to have seen a dinosaur and he smiled the whole way home, thinking about his special sighting.
<|endoftext|>
Once upon a time, there lived a little girl named Kate. She was 3 years old and loved to play with her toys. One day, she was playing with her stuffed cat, when she noticed a red spike on the ground. She picked it up and looked at it curiously.
"What is this little thing?" she asked her mom. Her mom smiled and said, "It's a printing spike. It can help you print your own stories and pictures."
Kate was very excited to hear this, so she tried to print something. She carefully pressed the spike onto her paper and, sure enough, a nice red print was made. "Wow!" she said with excitement. From then on, she used the printing spike to make all kinds of stories, pictures and designs.
Kate and her family were so proud of her. She had made so many red prints with her spike. From that day onwards, Kate was known as the printing queen.
<|endoftext|>
Once upon a time, there was a clumsy mole who lived in a big field. He was a very clumsy mole, and he was always tripping over his feet.
One day, the mole's best friend, a squirrel, came over for a visit. The mole was excited and asked his friend, "What should we do?"
The squirrel answered, "Let's cover things with leaves!"
The mole thought it was a great idea, so they spent the day covering things like rocks, trees, and even a hole in the ground with colorful leaves.
When they were done, the mole was tired and said, "This is fun! Let's do it again!"
The squirrel laughed and said, "Sure, let's do it tomorrow!"
The End.
<|endoftext|>
Once an day, Jimmy and his mum went to the park. Jimmy was so excited to go on a special adventure. He saw a big wheel and wanted to go on it. Together he and his mum hopped on the wheel and soon it began to zoom around!
Jimmy was so delighted to go so high, he started to laugh and waved at the birds flying around him. Eventually the wheel stopped and the operator gave Jimmy a prize for his bravery! Jimmy was so excited to receive a prize that he ran around the park in celebration.
On the way home, Jimmy's mum was a little frustrated. She wanted to find a shortcut to get home quicker, but no matter which way they went they seemed to end up back at the park. Frustrated she decided to take the long way home.
Jimmy didn't mind though and zoomed right by his mum all the way home, clutching his prize close. From that day Jimmy knew that he would always have an adventure with his mum!
<|endoftext|>
Once there was a girl named Sally who loved to dance. She was always moving around her house, singing and dancing. One night when Sally was dancing, her mom came in and put her to bed.
Before Sally went to sleep, she thought about dancing and imagined a peaceful place where she could dance forever. She closed her eyes and imagined a beautiful place full of trees and flowers. In the middle of the forest was a big, open grassy area where Sally could do her favorite dance.
Sally knew that if she slept well, she would be able to go to her peaceful place and dance the next day. So she went to sleep feeling peaceful and happy.
In the morning, Sally got to dance in her secret place. She moved around, twirling and jumping, smiling and laughing. As she danced, a warm breeze made her dance even more and she felt a peaceful feeling inside her heart.
Sally danced until she was tired and then she hugged herself and said: "I love to dance in my peaceful place, it makes me feel so happy."
<|endoftext|>
One sunny day, Jimmy found an old bicycle in the grass. It was hairy with lots of rust. He couldn't wait to try it! Jimmy ran to get his older brother Dave, who was very happy to help him.
"Let's push it to the street," said Dave. So they both grabbed the handle bars and pushed the old bicycle.
Suddenly, they heard a loud noise. It was Jimmy's dad! "You kids stop right now!" he said in a angry voice. Jimmy and Dave were scared.
But it was too late. When they looked down, they saw that a strange hairy creature surged out of the bike. It had sharp teeth and long claws. Then it angrily growled at Jimmy and Dave.
The two brothers ran away in terror, leaving the old bicycle behind. They never saw it again, or the creature that had grown out of it.
<|endoftext|>
Once upon a time there lived a shy little girl named Denise. Denise loved adventures and playing outside. One day Denise went to the beach and asked her mom if she could swim in the ocean. Her mom said to be careful, because there might be a hurricane coming.
Denise's mom was worried, but Denise wasn't scared. She felt like she could do anything. So Denise kept playing and swimming in the ocean.
After a while her mom noticed there was a storm coming. She yelled for Denise to come back and get out of the water. But Denise wanted to keep swimming. She wanted to prove that storms couldn't stop her.
Suddenly the scariness of the hurricane came closer and the waves were getting bigger and bigger. Denise was so frightened that she started to cry.
Her mom ran to Denise and said, "Honey, you were so brave, but you should always listen to me so you don't get hurt. You can be brave, but still be careful."
Denise hugged her mom and felt relieved. She had learned a very important lesson that day – you can be brave, but it's important to listen to the advice of others.
<|endoftext|>
Once upon a time, there was a naughty little mouse. His name was Peter. Peter liked to play all day and never listen to his mom.
One day, Peter took a walk in the forest. Suddenly, he saw something that made him blink - a secret door! He ran quickly to the door and peeked inside.
"Oh wow!" Peter said.
"Who goes there?" a voice said from inside.
Peter was so scared that he couldn't say a word. After a few moments, the voice spoke again.
"If you want to enter this secret door, you must answer a riddle. If you can't answer it, you must go away."
Peter thought for a minute and then asked, "What is the answer?"
The voice replied, "Beware the naughty ones!"
Peter smiled and said, "I know the answer! I'm naughty, but I'm also very curious! May I enter please?"
The voice laughed and said, "Yes, you may come in and explore the secret door!"
And so, Peter did. He explored the secret door with great curiosity and had many adventures!
<|endoftext|>
Once upon a time there was a small bunny called Alice. Alice liked to do things all by herself. She was very independent. One day Alice went to visit her friend. When she arrived there was a big fridge in the middle of the room. Alice had a great idea. She opened the fridge and found a big surprise. She saw yummy ice cream. She wanted to eat it all by herself, so she grabbed a bowl and the ice cream. She closed the fridge and enjoyed her ice cream. She remembered to always be independent.
The next day Alice and her friend were playing outside. Alice saw a fridge in the garden. She was so excited and rushed over. She opened it and saw something sparkly. It was a magic wand! Instinctively, Alice remembered what to do with the wand - make a wish. She closed the fridge and made her wish. She wished to always remember to be independent. In that moment, she felt so special.
Alice will never forget the magical moment when she found the magic wand in the fridge, and she will always remember to be independent.
<|endoftext|>
Once upon a time, there were two bears, Bob and Jenny. Bob was a young bear, and Jenny was an old bear. They were discussing the summer day.
"The sun is shining brightly and it's making the blossoms in the trees sparkle," said Jenny.
Bob looked at the ground and noticed the dust near his paws. "What's this dust?" he asked Jenny, pointing towards the dirt.
Jenny smiled. "That dust is from the old path," she said. "It's been here for many, many years."
Bob smiled back. He thought about the years that had gone by and how young he still was.
"Let's go find some new adventures!" he said with excitement.
And so they did. They explored the woods and enjoyed their summer day together.
<|endoftext|>
Once upon a time there was a little girl, who was very excited. She loved playing outside, especially in her garden. One day, when she was playing in the garden, she spotted something unusual. She saw a vine had started growing up one of the walls near her window.
"Wow, that's so cool!" the little girl exclaimed.
The vine kept growing and when the little girl returned to the garden, the vine had changed - it had now covered the entire wall!
The little girl was so excited that she ran inside to get some help. She quickly found her mommy and told her about the vine.
"Mommy, I want to climb the vine!" the little girl said, hopping from one foot to the other.
Her mommy smiled and said, "Okay, but be careful!"
The little girl carefully climbed the vine to the top of the wall, and she was so proud of herself. She was excited to have done something so special and was looking forward to doing it again!
<|endoftext|>
It was a hot summer day.
Lucy and her mom were out in the yard.
Lucy's mom was gardening and Lucy was playing with a ball.
Suddenly, Lucy's ball rolled towards the house and stopped at the back door.
Lucy went over to get the ball, but it was stuck in the door.
She called out to her mom, "Mommy, help!"
Her mom said, "I'm busy right now, but try to open the door yourself."
Lucy tried to open the door, but it wouldn't move. She was getting frustrated.
So she leaned her shoulder against the door and pushed as hard as she could.
Suddenly, the door opened revealing a filthy freezer.
It was filled with old food and had a nasty smell.
Lucy was so surprised that she jumped back. She asked, "Mommy, what is this?"
Her mom said, "It's a freezer, Lucy. We need to clean it up."
Lucy grabbed her mom's hand and said, "We can make it look like new!"
And so, with a lot of effort, Lucy and her mom cleaned the freezer until it looked brand new.
When they were done, Lucy smiled in satisfaction — her job was complete.
<|endoftext|>
Mommy and Daddy were eating dinner. Mommy said, "What do you want for dinner?" Daddy looked at the menu and said, "I can't decide. It looks difficult to choose."
Then Daddy had an idea. He said, "Let's play a game. I'll count to three and on three you will forget everything you were thinking."
Mommy said, "Ok, that sounds fun!"
So Daddy started counting, "One, two, three!" As soon as he said three, Mommy forgot everything and said, "I don't know what I want!"
Daddy smiled and said, "How about the mac and cheese?" Mommy smiled too and said, "Yes, that sounds good!"
So Daddy and Mommy ordered the mac and cheese for dinner. They both enjoyed it and had a happy evening together.
<|endoftext|>
Once upon a time there was a little girl called Lacy. She was very happy, playful and loved to explore her world.
Every day, Lacy had lots of fun as she played in her backyard. She always ran around the garden with the sun shining on her back.
One day, when Lacy was playing outside, she heard something in the bushes. She looked around and saw a small furry creature looking back at her. It was a tiny little fox, just like she had seen on TV. She was so excited and shouted, "Mine!"
The fox, who was also very playful, didn't run away and even came closer. Lacy started petting the fox and ever since then, the fox became her best friend.
From that day onward, Lacy and the fox went on many adventures together, running and playing through the garden and discovering the world around them.
Little did Lacy know that one day, the fox would protect her from danger. But that's a story for another day!
<|endoftext|>
Once upon a time, there was a chubby little girl called Daisy. Daisy loved her mummy and daddy very much, and she spent every day playing with them.
One day, Daisy went to play in the garden. While she was there, she found a beautiful crystal lying in the grass. It glittered in the sunshine and Daisy thought it was magical. She wanted to keep it for herself.
Daisy put it in her pocket and ran back to the house to show mummy and daddy. But when she got there, she saw that someone had disturbed the living room. Everything was in a mess and her parents were nowhere to be seen.
Poor Daisy started to cry. She was scared and she didn't know what had happened. She was so upset that she dropped the crystal and it made a loud noise when it hit the ground.
At that moment, the bad robbers returned to the house. The crystal made them angry and they chased Daisy out of the house.
They never saw Daisy again. Her parents were so sad that she was gone. Daisy's chubby little face never returned to the house again.
<|endoftext|>
"What are you doing grandma?" asked Charles.
"I'm adding yarn" said grandma.
"Wow! What a lot of yarn!" said Charles.
He watched as grandma wound the high yarn around her fingers and added more.
"Why are you making yarn?" asked Charles.
"I'm making a special scarf for your mom's birthday," said grandma.
Charles smiled.
"Can I help you add the yarn?" he asked.
Grandma smiled and gave Charles some yarn to add.
They spent the rest of the afternoon adding the yarn together. They laughed and sang as they worked.
At the end of the day, the scarf was finished. It was a long, high scarf, full of many colors.
Charles was so proud of the finished scarf. "That looks wonderful" said Charles.
Grandma smiled. "It sure does," she said. "It was so nice to have your help in adding the yarn. You did a great job."
<|endoftext|>
Ben and his dad walked through the swamp. Everywhere there were logs lying around. Dad was looking for a perfect log to take home.
"Where's the perfect log?", Dad asked Ben.
Ben looked around. Everywhere was wet and somebody had put lots of logs there.
Dad became impatient. "Maybe if we struggle to find the log it will help," Dad said.
Ben started feeling around the logs and pushing them to see which was the perfect log for Dad. At last, Ben found the perfect log and gave it to Dad.
Dad was so happy. He thanked Ben for his help. Together they took the log home.
<|endoftext|>
Once upon a time, there lived a young girl. Her name was Molly and she was three years old. Molly's mummy was so proud of her daughter.
One day, Molly was feeling a bit wild. She wanted to do something daring. So, she asked her Mum, "Mummy, can I wear a skirt?"
Mummy thought carefully and then suggested, "Why don't you try wearing a shorts? Wearing a skirt is a bit difficult."
Molly thought this was a great idea. She got very excited and ran to her wardrobe to find a nice pair of shorts
<|endoftext|>
Mummy and John were in the park. John was eating his ice-cream, while Mummy was talking to a friend. Suddenly, John felt embarrassed as he saw everyone around them staring at him. He quickly tried to hide the ice-cream behind his back.
Mummy noticed his embarrassment and asked, "What's wrong, John?"
John replied, "They are all looking at me."
Mummy smiled and said, "That's normal, the ice-cream is yummy, why don't you show it to them?"
John reluctantly put the ice-cream back in his hand and tried to smile, but the other children kept staring at him. He felt even more embarrassed and started to cry.
Mummy hugged him and said, "That's ok, everyone makes mistakes. Let's go home now."
John sadly nodded and Mummy took him home. The ice-cream was all gone, but the embarrassment he felt was not.
<|endoftext|>
Jack and Jill were walking up the hill. Jack said to Jill, "I am thirsty. Let's get some water from the river."
They quickly ran to the riverbank. Jack was surprised to see the river was dry! He asked Jill, "What are we going to do now?"
Jill pointed to an old man in a tip. She said, "That man might be able to help us."
Jack and Jill ran to the old man. He said, "Don't worry children, I can supply you with some water." He then took out a bottle of cool and refreshing water.
Jack and Jill thanked the old man, and he said, "You children should always remember to be helpful and kind to others." They said goodbye and walked away with their water.
Jack and Jill enjoyed their cool and dry water, and they were thankful they had been able to find help.
<|endoftext|>
Once upon a time, Mummy, Daddy and their daughter, Isabel, sat down at the dinner table. Daddy looked at Isabel and asked her what she wanted to discuss. She smiled and said she wanted to talk about something unusual.
Mummy and Daddy started to discuss dinner and Isabel heard them talk about something unusual. She wondered what it was and asked them what it was. Mummy said that it was a special dinner that she had cooked. She had put lots of unusual ingredients together, like carrots, celery and some strange spices.
Isabel was very excited and couldn't wait to see what it tasted like. Mummy smiled and said the dinner was a surprise and that Isabel would have to wait until it was ready. After a short while, Mummy brought in the dinner. When Isabel saw it, her eyes went wide. It looked so delicious!
Mummy asked Isabel what she thought of the dinner. Isabel said it was the most unusual dinner she had ever seen. She tried a bit of everything and said it tasted delicious.
Mummy, Daddy and Isabel all smiled as they enjoyed the dinner together. Every time they ate dinner after that, Isabel would always ask if there was something unusual to talk about!
<|endoftext|>
Henry loved to learn about the world. He loved to watch people and see what they did. One day, Henry went for a walk and saw a smooth lake. He wanted to learn how to swim but he had some trouble. He kept trying, but he couldn't get the hang of it.
After many attempts, he got frustrated. He felt like giving up. But he kept trying until he finally learned how to swim. He was so proud when he could swim smoothly. He learned that if he worked hard and kept trying, he could achieve anything. He learned a valuable lesson that day.
<|endoftext|>
Once there was an old man. He saw an old brick and thought it would be fun to take it home to play with. So he went to steal it.
He was hiding behind a tree when he heard someone coming. He saw it was a little girl. She looked at the old brick and said, "That'll be nice to have for building my house."
The old man said, "You can't take that. I'm going to steal it for myself."
The little girl replied, "Well, you can't do that. That's not nice."
The old man thought for a minute. Then he said, "How about I share it with you? We can both have it and play together."
The little girl smiled and said, "Yes, that sounds fun!"
So they both took the old brick home and had lots of fun building together.
<|endoftext|>
The sun showed its face in the morning sky and it shone brightly. The birds flew up to the sky and sang their happy song.
Then, a little girl named Lucy came out of her house and looked up. She saw the bright sun and the fluffy clouds. She was so happy that she jumped up with excitement!
Lucy: "Look at the beautiful clouds! I wish I could go up and touch them!"
Suddenly, there was a rumble in the sky. Something had blocked out the sun and the sky had become dark.
Lucy looked up and saw that a big selfish cloud had come between the sun and the sky.
Lucy: "No, not that selfish cloud! Get away!"
But the selfish cloud didn't move. It just stayed there and blocked out the sun.
Lucy was sad and she slowly walked back to her house. The sun slowly returned and the sky became sunny and bright once again.
Lucy was surprised that the selfish cloud had gone away. She was so happy that she smiled and shouted in joy.
Lucy: "Yay! Thank goodness the selfish cloud is gone!"
<|endoftext|>
Once upon a time, there was a girl. She was very excited, because her mom had just given her a surprise. It was a special present—a red pedal car! She could go anywhere she wanted with it. Her mom also said she had to be organized when driving it.
The girl was a bit scared at first, but then she felt brave. She thought it looked fun, so she asked her mom if she could go for a drive. Her mom said yes and gave her a permit to be in the streets.
The girl put on her helmet and safety vest, then she hopped into her pedal car. She started pedaling as soon as she could. She was so happy and excited to explore the world and feel the wind in her face.
She drove around the town, meeting all kinds of people. She went over the hills, up and down the roads, and everywhere felt different. Everyone said hello and waved to her, and it made her smile.
By the end of the day, the girl felt so proud. She drove the pedal car so well, and it was all because her mom had taught her how to be organized. She thanked her mom for the special present and promised to be careful when outside in the streets.
The girl then grabbed her permit and her special pedal car, hopped in, and drove off into the sunset.
<|endoftext|>
Little Jack was so proud of his igloo. It was the biggest one in the neighbourhood and he had worked so hard on it with his dad.
Little Jack's dad called to him from the porch. "Let's go for a walk!" he said.
Jack eagerly jumped up and ran over. "Where will we go?" he asked.
Dad smiled. "Let's go and visit the Arctic Igloos," he replied.
Little Jack was so excited. He ran ahead of his dad as they made their way to the igloo village. As they got closer and closer, they could see all the igloos in their bright colours.
Little Jack gasped in amazement. Dad pointed to the biggest one in the village. "I bet that's the most important one," he said.
Little Jack smiled. His dad was right. He ran ahead and urged his dad to follow. As they got closer, Jack could see his dad's proud smile.
<|endoftext|>
Once upon a time there was a heavy truck. The truck belonged to a man called Ben. One day, the truck stopped working, so Ben took it to a mechanic.
When Ben arrived at the mechanic's shop, the mechanic told him that the truck had frozen. He said it needed fixing before Ben could drive it away.
Ben asked the mechanic, "Can you fix it?"
The mechanic looked at the truck and said, "Yes, I will fix it. But it will take me some time."
So Ben left the truck at the mechanic's shop and came back a few days later.
When he arrived, the mechanic said, "It is fixed! You can drive your truck away now."
Ben was so happy. He drove the truck home, and it never froze again.
<|endoftext|>
Once upon a time there were two friends, Jack and Lea. They were playing in the park one day when Jack said, "Let's do an exercise!"
Lea said, "What's an exercise?"
Jack said, "It's a rare thing that we can measure. It's a thing that makes us feel strong and happy. It's fun!"
The two friends ran around in circles, then jumped up and clapped their hands. After that, they sat down and counted the number of jumps they had done. Then Jack said, "We did a big exercise! Let's do more!"
The two friends continued to have fun while they did their exercises. And they felt very proud of themselves when they measured their progress.
The end.
<|endoftext|>
Once upon a time there was a little girl called Max. Max loved to play outside in the sunshine. One day, while she was playing, a big bad monster appeared. The monster had three heads and wiggly arms.
Max was scared and wanted to run away. But the monster offered her some sweets. "If you come a bit closer, I can give you some nice sweets," said the monster.
Max was still scared and didn't want to get too close. But then the monster said, "I won't hurt you. I just want to give you a gentle touch to show I'm a nice monster." Max could see the monster looked different than usual monsters and decided to take a closer look.
She reached out to take the sweets and noticed the monster was giving her a gentle touch instead of a bad one. Max started to feel much better. After that, they became friends and they would often play together in the sunshine.
<|endoftext|>
Once upon a time there was a little girl called Amy. She was three years old and she had a pet puppy. The puppy was very playful and always running around the garden. But one day, Amy's mommy put up a fence in the garden made of wire. It was very high and the puppy was sad that she couldn't play as much anymore.
That night, Amy noticed the puppy outside the fence, trying to get back in the garden. She asked her mommy why the puppy couldn't get in, and her mommy said the fence was there to make sure the puppy behaved.
Amy felt frustrated. Even though she understood why the fence was there, she wanted to make her puppy happy. And so she decided to find a way for her puppy to still have fun.
The next day, Amy and her puppy went for a walk and she discovered a park with lots of wide open spaces and interesting toys. She brought the puppy to this park everyday so that it could have fun and use up its energy.
Amy was very happy that she had solved the problem. Her puppy was behaving and was happy again.
<|endoftext|>
Once upon a time there was a young girl who lived in a small house. One day she decided to go for a walk in the woods near her house. While she was walking, she saw a small door in the ground. She used all her strength to push it open and saw some stairs that led up to an attic.
She went up the stairs and when she entered the attic, she saw someone. He was dressed in all black and he looked like he was in a hurry. He spoke to the young girl, "You should not be here. Hurry, go back the way you came".
The young girl was scared and she quickly ran back the way she had come. But before she could get very far away, the man chasing her appeared. He was coming closer and closer.
The young girl started to cry and she ran faster, but she couldn't outrun the man. He quickly caught up to her and grabbed her.
The young girl was never seen again.
<|endoftext|>
One day there was a clever radio. It sang lovely songs and made everyone happy. But then something strange happened. The radio began to split in two. It split and split until the pieces were very small. Everyone was so sad to see their clever radio fall apart. But then a very special thing happened. A man came and fixed the radio, and soon it was singing again. Everyone was so happy and cheered that their clever radio was back!
<|endoftext|>
Minnie was a three year old girl who loved to explore. One day, she decided to investigate an old house in the woods. As she started to look around, she noticed a message written on the door - it said "tough times ahead". Minnie was confused by this, but she knew it was something important.
She kept exploring and soon she heard a man's voice. He was talking about something called a "message". Minnie had no idea what he meant and she walked up to him to ask. He explained to her that a message was a way to tell someone about something important.
Minnie was still a bit confused but the man reassured her and said, "Whenever you miss someone, you can send them a message." He showed her how to write a message and soon Minnie was on her way with a note in her pocket.
When she got home, she shared the note with her family who hugged her tight and said: "We always miss you when you're away". Minnie smiled, feeling extra special and safe. She had learned an important lesson - tough times can be made better with a simple message.
<|endoftext|>
Once upon a time there was a car. The car was slow and it made the driver feel sad. The driver said, "I wish I could make my car go faster."
The driver's friend said, "I have an idea, let's try to improve your car!"
The driver was so happy. The friend and the driver began to work on the car. First, they made sure the wheels were tight. Then, they put some new oil in the engine so it would run better.
When they finished, the driver started the car to see how it ran. The car roared to life and drove faster than before. The driver and his friend were so happy!
The driver said, "I knew we could improve my car!" They were both so proud of their work. Now the driver can get where he needs to go faster.
<|endoftext|>
Once upon a time, there lived a little boy named Jimmy. One cold day, Jimmy was playing with a knife in his yard. He thought it was fun to use the knife to cut things.
Out of the corner of his eye, Jimmy saw his dad, who said to him, "Jimmy, knives are not toys. You must be very careful with them, or you could get hurt!"
Jimmy was scared and put the knife away. From then on, he was more careful whenever he was holding a knife.
The moral of the story is that we should always increase our care and caution when using sharp objects like knives.
<|endoftext|>
Once upon a time there was a girl called Emma. Emma was very obedient. One morning, Emma went into her classroom. As she entered, she saw her teacher sat at the desk. Emma said “Hello teacher” and smiled. The teacher smiled back and said, “Hello Emma, it's nice to see you.”
Emma walked over to the desk and put her bag down. She had some pencils in her bag.
The teacher said, “Emma, I want you to be obedient and write your name on the whiteboard.” Emma nodded and started to write her name carefully.
When she had finished, the teacher said, “Well done, Emma. You have been very obedient. You can sit back down at the desk now.” Emma smiled and went back to her desk. She was proud of herself for being obedient. She was happy to be in her classroom.
<|endoftext|>
Once upon a time there was a girl called Molly. She was three years old and loved learning new things. One day she saw something new, she did not know what it was called. It was a big green thing. She asked her mother, "What is that thing?" Her mother smiled and said: "It's called a plant. Would you like to learn about it?"
Molly was very excited and said: "Yes, please!" Her mother introduced her to the plant and explained how to take care of it. She said: "You need to water it every day, so it will stay healthy". Molly really wanted to make her new plant happy.
Every day, she would water the plant and scream out happiness whenever she saw it grow. She was so happy when she saw the plant grow bigger and bigger. She was very persistent in taking care of the plant, and she never stopped. Finally, the plant blossomed and Molly was so proud. From then on, Molly introduced her plant to everyone she knew.
<|endoftext|>
Once upon a time, there were two people who were very happy - their names were Jack and Jane.
They loved each other very much, and so they decided to get married. They had a big party, and all the people at the party were happy and excited.
After they got married, Jack and Jane went to sleep in their cozy bed. They were so tired from all the excitement that they fell asleep very quickly.
The next morning, Jack and Jane woke up and hugged each other. They were very happy because they were married now, and they loved each other very much.
Jack and Jane were so happy that they went back to sleep, cuddling each other. So they slept and stayed very tired, but they were still very happy and in love.
The end.
<|endoftext|>
Once upon a time, there was a bear. The bear was walking through the woods when he heard a loud snap. He looked around and saw a curtain hanging down from a branch. He was curious, so he went to see what had made the noise. There, he found a little mouse. The poor mouse had gotten its tail caught on a twig and had snapped it off. The bear was very sad, he could tell the mouse was hurt.
He looked around and found a soft leaf to wrap up the mouse's tail. He kept it safe until the mouse felt better. Then, he hung the curtain over a branch to make a cozy home for the mouse. The mouse thanked the bear and said goodbye as he scampered off into the woods. The bear was glad he was able to help the little mouse and make sure it didn't get hurt anymore.
<|endoftext|>
John was a little boy. He loved to go outside to play with the birds and trees. One day, he went out to the park. The sun was shining and the trees were blowing in the wind.
John felt so powerful. He felt like he could fly. He started to run and jump around and feel graceful like a bird.
Suddenly, John fell to the ground. He cried out for help. A man came running to help him.
The man spoke, “You were being too brave and over confident. You cannot use your power like that.”
John felt sad. He learned a lesson he would never forget. He knew he had to be more careful.
John never went outside to play again. He was too scared to feel the powerful, graceful energy again.
<|endoftext|>
Once upon a time there was a thin tower. It was so tall that it stretched up into the clouds. Every day a girl would come and stare up at it.
She enjoyed watching it, and the tower seemed to watch her back. One day, the girl couldn't take her eyes off the tower. There was a feeling in her gut that something special was about to happen.
The girl made a wish. Suddenly, a loud boom filled the sky. The tower was beginning to fall! It was tumbling slowly to the ground.
The girl had been wishing that the tower would get closer so she could touch it. And her wish had come true! The tower came so close that the girl could reach up and touch it.
The girl felt happy and amazed. This was the best day ever!
<|endoftext|>
Once there was a boy named Jack. He was three years old and he loved playing with his friends. One day, he was walking in the park when he saw a glove on the ground. He picked it up and asked himself, "Whose glove is this?"
He looked around but there was no one in sight. Then he came upon an old man and asked, "Excuse me, sir, can you answer me? Whose glove is this?"
The old man smiled and said "Ah, this glove belongs to me. I must have dropped it while I was walking. Thank you for finding it."
Jack was happy that he solved the mystery of the glove. But then he remembered something. He asked the old man, "Can I have your glove? It's so soft and looks very easy to use."
The old man thought for a moment and then said, "Yes, you may have the glove. I think it would make a wonderful present for you."
Jack smiled and thanked the old man. From then on, he kept the glove with him everywhere he went!
<|endoftext|>
Once upon a time, there was a pretty kitty who lived with its mommy in a nice home. The kitty was always so careful, but one day it noticed something strange. A thief had snuck into their home while they were sleeping. The kitty grazed the furry creature and soon realized it was not its mommy.
The thief was scared, so it quickly ran away. The kitty jumped up and chased after it. The thief could not get away fast enough, but it was still able to make it far away. Mommy came out of the house and saw the kitty gone. She called for her, but the kitty was too far away and couldn't hear.
Mommy searched the entire neighborhood, but she couldn't recognize the thief or the kitty. She started to get scared and soon worried that the thief had taken away her pretty kitty. After much searching, she sadly went home without the kitty. The kitty never returned home and was never seen again.
<|endoftext|>
One day, a little boy was playing in his garden. He was excited to feel the sun on his face and the grass beneath his feet. Suddenly, he noticed a spider crawling towards him. He became scared and started to move away.
The spider started chasing the little boy, who ran back and forth, looking for a place to hide. He was frustrated that the spider kept following him. Just then, the boy's mother appeared. She said, "What is going on here?"
The little boy replied, "Mummy, there's a spider chasing me. I don't like it."
His mother smiled and said, "That's okay. Spiders won't hurt you. Just try and stay calm and relax."
The little boy tried to take a deep breath and slowly, he began to feel less scared. He said, "Okay, I'm not scared anymore." The spider soon stopped chasing him and he was no longer frustrated. He smiled and said, "Thank you, Mummy!"
<|endoftext|>
Mary and James were happily playing together in the summer sunshine. Mary thought to herself that summer was very attractive. She smiled, then said to James, "Let's add something to our game."
"What should we add?" asked James.
"What about if we pretend there is a cave under the tree, and we have to explore it. We can take a stick and a pretend map!" Mary replied.
James's eyes lit up with excitement. "That sounds great!"
Mary and James gathered some sticks and stones, and began their adventures. They pretended they were discovering all kinds of things in their pretend cave, and enjoyed their game so much they didn't want to stop.
The two friends made up amazing stories as they explored, adding new ideas to their game. Summer was the best time to adventure together and have lots of fun!
<|endoftext|>
Once there was a very shy 3 year old named Andy. He liked to play with his many teddy bears, but he wasn't sure what to do when he was outside. One day, Andy's mom took him to the park.
Andy was scared and didn't want to join the other kids. His mom said, "Come on, Andy. You will learn something here, and it will be fun too!"
At first, Andy was hesitant, but eventually, he gathered his courage and went to the playground. He felt a bit dull there, but he soon found out that he could make new friends. In addition, he was able to learn all kinds of things in the park.
Each day, Andy spent time in the park with his new friends. He learned how to climb up a tall slide, prices of different things he saw, how to swing with grace, and more.
When it was time to leave, Andy was sad. He thanked his mom and said, "I want to come to the park everyday. It was really fun to learn so many things here!"
<|endoftext|>
It was a hot day and Sandy and her mommy were at the park. Sandy blinked in the bright sunlight and looked around. Everything was so much fun.
Suddenly, Sandy saw a butterfly fluttering in the sky. She was mesmerized. She started to walk towards it when her mommy yelled "wait, Sandy!"
Sandy stopped and looked back at her mommy. Her mommy blinked and smiled. "Let's go and have a picnic," she said.
So they spread a blanket on the grass and unpacked the food. While they ate, the butterfly flew down and landed on Sandy's shoulder. Sandy gasped in surprise and smiled. She closed her eyes and blinked slowly. She felt so happy.
Afterwards, Sandy and her mommy packed everything away and headed home. Sandy couldn't stop smiling. She promised herself that she would always remember that special day at the park.
<|endoftext|>
Once upon a time, there was a little boy named Tom. Tom loved to look up at the sky every night. He would often see a comet speeding by and it would always make him happy.
One night, Tom was a bit worried because he couldn't see the comet. He asked his mom, "Mom, where is the comet? Why can't I see it?" His mom smiled warmly and said, "Don't worry, Tom. It will rise again soon."
Tom was confused. He asked, "What does that mean?" His mom explained, "It means that it will appear again. Everyone and everything has their ups and downs, just like the comet. Just be patient and it will come back to us."
Tom nodded and looked up at the night sky. He was no longer worried. He knew that everything will come back even if it seems to be gone for a while.
Tom had learned a valuable lesson from his mom: don't worry even if something is gone for a while. It will rise again.
<|endoftext|>
Kari was so excited. She was going to the park. "Mum, can I take the blocks?" She asked.
Mum said yes and gave Kari a bag full of blocks.
At the park, Kari found a big tree and sat in the shade. Then she looked around and noticed another child playing with some blocks.
Kari was jealous. She wanted to play with the blocks, too. She began to cry.
The other child came over to Kari. "You can play with me," he said. Kari felt much better and was very happy.
The two of them played with the blocks together. They built a tower that was very tall. Kari was so proud of what they had built.
Mum watched them from a distance and smiled. She said, "I'm so glad you found a friend to play with."
<|endoftext|>
Jimmy was swinging in the playground. He loved being high up in the air and how it made him feel so light. His friends were there too and everyone was having a great time.
Suddenly, Jimmy heard a loud noise. He stopped swinging and looked around. He saw a jar lying on the ground near the swing. He ran to it and picked it up. The jar had a gentle pattern, with blue and yellow flowers.
Jimmy brought the jar closer to his eyes and saw a ladybug crawling around inside. It was really tiny. He smiled and called his friends.
"Look what I found!" he said.
His friends gathered around him and all looked at the little lady bug. They oohed and ahhed and said it was so cute.
Then the lady bug stopped and Jimmy decided to set it free. He opened the jar's lid and gently turned it upside down. The lady bug hopped out and flew off into the sky, free to explore its new world.
Jimmy smiled and watched until it was out of sight. Then he went back to swing with his friends. That had been an exciting find and he couldn't wait to tell his mom about it when he got home!
<|endoftext|>
Once there was a generous bear. He liked to help others and was always very kind. But he had one habit that no one really knew about: he loved to eat clay!
Every day he would go outside and search for clay in the woods. Then he would find a quiet spot, sit down and take a bite of the delicious clay.
One day, he stumbled across two little kittens. They were feeling scared and alone, so the bear was very generous. He shared some of his clay with them and the kittens were so happy.
The bear and the kittens became fast friends, and they would go out into the woods every day searching for clay. Sure enough, they always seemed to find enough clay for everyone, and soon enough it became a daily ritual.
It was a wonderful friendship that would last for years - and all because of the generous bear, who was always willing to share his clay with others.
<|endoftext|>
Once upon a time, there was a farmer who wanted to buy something special. He had a rare barn and wanted to give it an extra sparkle. So he went out to buy the perfect thing.
The farmer searched and searched, but nothing seemed quite right. Then, he stumbled upon something quite unique - a shiny diamond! It was so rare, the farmer knew this was the perfect thing to put in his barn.
The farmer bought the diamond and took it back to his barn. To his surprise, when the diamond was placed in the barn it lit up the entire space – like a never ending twinkle! Everyone who had visited the farm was in awe of this magical sight. The barn had become rarer than ever before!
The farmer was so happy with his purchase. He now had a truly special barn, better than ever before. And so, the farmer and the diamond lived happily ever after.
<|endoftext|>
Once upon a time there was a boy named Frank. Frank loved to play with his sock. He thought it was so fun to throw the sock in the air and catch it. One day, Frank jumped into his garden and decided to play forever. He threw the sock up as high as he could and ran to catch it. He ran so fast that, poof! The sock disappeared.
Frank was very confused. He started thinking about where the sock had gone. He looked up in the sky and shouted, “sock, where are you?!”
Just then, Frank heard a voice from up above. “I'm up here!” it said. Frank looked up and saw the sock floating in the air.
The sock said, “I'm flying now! I jumped up so fast that I flew into the sky!”
Frank laughed. He waved goodbye to the sock and ran off to find something else to play with.
<|endoftext|>
Once upon a time, there was a little girl named Jacky. Jacky loved playing with her helicopter. She liked to fly it high in the sky and spin around and around.
One day, Jacky wanted to take her helicopter for a ride around the park. She put on her shoes and off she went.
At the park, Jacky was enjoying flying in the sky when all of a sudden, a big gust of wind came and her helicopter landed in a pond.
Jacky was very upset and started to cry. Suddenly, an attractive horse came galloping over and said, "Don't worry Jacky. I can help you get your helicopter out of the pond."
Jacky said, " really?! How?
The horse said, " With a fight. See, if I fight against the pond with all of my strength, I will be able to get your helicopter out".
Jacky was amazed and said, "Thanks a lot!"
So the horse fought hard against the pond and in the end it was victorious. The helicopter was safe and sound!
Jacky was so happy that she hugged the horse and thanked it.
From that day on, Jacky and the horse were the best of friends. Jacky would take her helicopter for a ride and the horse would run beside her. It was a beautiful sight to see.
<|endoftext|>
Clarissa was feeling very grumpy as she watched the soldiers walk by. "What's wrong?" Her mother asked. "Why don't you play with them in the garden?"
Clarissa shook her head, "No. I don't like the soldiers." But her mother smiled and said, "Maybe you'll change your mind. Come and play with them in the garden".
So Clarissa went outside. She thought about running away but everything inside her was telling her to give them a chance. As she stepped out of the house, the soldiers saw her and called her name.
Clarissa was still feeling grumpy so instead of walking toward them, she ran away and started to weep. The soldiers were startled by her reaction but they followed her anyway and finally caught up to her.
"What's wrong?" Asked one of the soldiers. Clarissa wiped her eyes and said, "I was just thinking that sometimes you have to give people a chance". And with that, the soldiers welcomed her as a friend and she learned that soldiers were not so scary after all.
<|endoftext|>
Once upon a time there was a little girl named Jane. She was only three years old.
One day, she asked her mom for something sweet. Her mom said yes and gave her a blueberry muffin. Jane was so happy! She remembered how sweet it tasted and wanted more.
The next day, Jane asked her mom for another muffin. Her mom laughed and said, "Oh no sweetheart, one is enough for today."
But Jane didn't remember what her mom said. She kept asking for a muffin. Her mom got tired of her requests and said, "No, Jane. No more muffins today."
Jane was sad, but she didn't give up. She kept asking for a muffin and started to cry. Her mom eventually got angry and said, "That's it! No more muffins for you ever again."
Jane was so sad. She would never get to eat her favorite sweet treat again.
<|endoftext|>
Once upon a time, there were two friends who loved to play together. One day, they played a game of hide and seek. After a few minutes, one of them found the other. But when he found his friend, he saw that his friend had an itch. He asked, "What's wrong? Why do you have an itch?" His friend replied, "My shirt is dirty, and it's making me itchy."
The friend then had a brilliant idea! He said, "Let's share! I have a clean shirt here that I can give you!" His friend was so happy and he agreed to take the shirt. The friends shared the shirt, and the friend with the itch was now feeling much better.
They both laughed out loud and hugged each other to celebrate their special moment. Then they continued to play until it was time to go home. They were very happy, both with their special moment as well as sharing the shirt – it was a perfect day!
<|endoftext|>
Bob and Sue were going to a party. They were celebrating Sue's birthday. When they arrived, Bob started kicking the ball around. He was having lots of fun. But before long, Sue came over and said, "No, Bob, don't be so foolish. It's my birthday party!" Bob stopped to listen, then gave the ball a big kick. He and Sue laughed and ran around the party together. Everyone had a great time.
<|endoftext|>
The sun shone brightly in the sky, making the grass very dry.
Tommy and his dad were outside playing football. Tommy enjoyed playing football with his dad very much.
Suddenly, Tommy started to sneeze. He sneezed so hard that he dropped the football.
His dad said, "Bless you, Tommy. Take a break and have a drink of water."
Tommy sat down and drank his water. After a few sips, he felt much better.
He said to his dad, "Can we play some more football now? It's a lot of fun!"
His dad smiled and said, "Yes, let's go!"
They started playing football again and had a great time. Tommy never wanted the day to end.
<|endoftext|>
Once upon a time, there was a brave bear called Bob. Every day, Bob would take his friend, a little rabbit, with him on all his adventures.
One day, Bob saw an interesting zigzag path in the forest. He urgently wanted to explore it, so he urged his friend to join him.
"Let's go, Rabbit! It's gonna be an exciting journey!" he exclaimed.
But Rabbit was feeling a bit afraid. "It's very dry and there are so many zigzags," he said nervously.
"Don't worry," said Bob reassuringly, "I'm here with you. Nothing bad will happen."
Rabbit felt a bit better. With a happy heart, he followed Bob onto the zigzag path. Together, they explored the mysterious path and had a great adventure!
<|endoftext|>
The sun was shining brightly as John stepped out of his tiny house. He was an ignorant child who loved nothing more than running and playing. He had an old sheet he used as a blanket and he often imagined himself as a superhero.
John always wanted someone to play with but there was nobody around. Sighing, he decided he'd find someone. On his way out of town, he heard two voices, one of which was quite familiar. He recognized the voice of his neighbor, old Mrs. Johnson.
John walked closer, hiding behind a bush and peaked through the branches. Mrs. Johnson and a stranger were talking and the stranger seemed to be angry about something. Suddenly, the stranger shouted and stepped towards Mrs. Johnson. John was scared and decided to go back home, but before he could do so, the stranger noticed him.
The stranger ran towards John, who screamed and tried to escape. But the stranger was faster than him and eventually caught him. The stranger threatened to take John away, saying something about his family having done something wrong.
John began to cry and pleaded to be let go, but the stranger remained firm. In the end, the stranger took old John away, never to be seen again.
<|endoftext|>
Once upon a time, there was a very fast onion named Gary. He was so fast, that he could even race the wind. He liked to brag about his speed to all of his friends.
One day, Gary decided to challenge the wind to a race. He wanted to prove that he was even faster than the wind. So, he zoomed off without a thought!
When Gary approached the wind his friends were worried. They shouted out to Gary to quit the race and come back, but Gary didn't listen. He wanted to prove that he was the fastest.
The wind started to pick up and Gary was struggling to keep up. Soon enough, he was too tired to keep up with the wind and Gary had to quit the race.
Poor Gary! All this excitement had been for nothing.
Despite his failure, Gary's friends assured him that he was still the fastest onion that they ever knew.
The moral of this story? It's important to remember your limits and to quit when things get too hard.
<|endoftext|>
Once upon a time, there was a patient nurse. Her name was Sarah and she worked at a hospital. Every day, she looked after the children and made them feel better.
One day, Sarah was taking care of a 3 year old boy called John. He was feeling unwell and was very upset.
“John, why don't you come and sit with me?” said Sarah kindly.
John shook his head and said, “No, I want to stay in my room.”
Sarah was very understanding and said, “That's okay. I'll be here when you need me.”
John walked into his room and shut the door. He was feeling scared and lonely.
Soon, Sarah heard him crying and opened the door. She said, “It's okay, John. I'm here to help you feel better.”
John looked at the kind nurse and smiled. He was happy to have a patient nurse by his side to help him feel better.
<|endoftext|>
One sunny day, Lily and her mom were walking in the park. Lily loved the park; she could smell the sweet smell of nature, and enjoy the sunshine on her face.
"Mom, let's go play on the slides," Lily said, as they passed the playground.
"Okay," her mom said with a smile.
Lily ran over to the slide, but as she tried to climb the ladder, she began to slip. She grabbed onto the rungs, but soon both of her feet were in the air.
"Oh no!" Lily said, feeling embarrassed.
Her mom ran over, and caught her in her arms. Lily looked up at her mom's eye, and saw how sweetly she was smiling.
"We'll try again," her mom said, lifting her up and setting her back down on the ladder.
Lily began climbing again, and this time, she made it all the way up to the top. She gave a victorious smile, then quickly slipped down the slide.
<|endoftext|>
Once upon a time, there was a little girl called Alice. She was three years old and very obedient.
One day, her parents took her to the beach. As they strolled along the shore, Alice spotted something shiny in the sand. She ran over to a spot and started to dig.
She pulled out a silver key! She jumped up and down and shouted, "I've found a key!".
Her parents laughed and asked her what she thought the key unlocked.
Alice considered this and frowned. She then smiled and said, "Maybe it unlocks an adventure!"
Her parents smiled and hugged her. They then all started out together, determined to discover the secret of the silver key.
<|endoftext|>
Once upon a time, there was a little girl who was very eager to play the violin. She looked at her mum and asked, "Mum, can I grab my violin?" Her mum smiled and said, "Of course, sweetheart!"
The little girl ran over to the violin case and grabbed the instrument. With a big smile on her face, she hugged it close.
The mum watched as her daughter played and felt happy that her child was so eager. With every note she played, the little girl's face lit up with joy.
At the end of the song, the mum smiled and said, "That was beautiful, sweetheart!" The little girl smiled back and gave her mum a big hug.
<|endoftext|>
Once upon a time there were two friends, Sam and Joe. Sam and Joe wanted to go outside and play, but it was so cold! Sam said, "It's too cold, let's go inside where it's warm."
Joe said, "No way! I'm ready for a challenge."
Then, he slowly walked outside, and Sam followed him.
Suddenly, a strong gust of wind struck them. Joe shivered, then said, "It's too cold, let's go back inside."
Sam smiled and said, "I have an idea! Let's play a game."
The two friends played their game, and had lots of fun. Joe said, "It's not so cold anymore."
They kept playing until it was time to go home. Sam and Joe were glad they had braved the cold and enjoyed their game.
<|endoftext|>
Once upon a time, there was a little girl called Maisy. She was playing in her bedroom when she saw a big chest in the corner. Maisy was very curious, so she walked over to the chest and opened it. Inside she found lots of toys! Maisy was so excited that she grabbed the toys and started to play.
Suddenly, her older brother Oliver burst into the room. "Put those back!" he said in a loud bossy voice. Maisy was so scared, she quickly put the toys back in the chest and shut the lid. She started to cry.
Oliver saw her crying and said, "Don't worry, I won't be mad. You can play with the toys if you want. I just don't want you to make a mess in here!" Maisy smiled and said, "Thank you, Oliver!" She was so happy that she opened the chest and started playing with her toys.
<|endoftext|>
Jenny and her mom were walking in the park one day. Suddenly they noticed a raven on a nearby tree. Jenny asked her mom who the little black bird was. Her mom smiled and said, "That's a raven."
Jenny smiled and nodded her head in agreement. "Oh, look how tidy it is!" she said as it fluffed up its feathers.
The raven seemed to be enjoying the warm day. It cocked its head this way and that, trying to catch sounds of the forest.
Then it took off in the air and flew away. Jenny watched it and waved goodbye. She smiled and said, "Goodbye, Mr. Raven!"
Her mom put her arm around Jenny and said, "Let's go get some ice cream. Doesn't that sound nice?"
Jenny's eyes lit up and she nodded her head, saying, "Yes!". She seemed very eager to get some ice cream.
So off they went, happy to enjoy the day together.
<|endoftext|>
It was a gloomy day outside, but Sarah wanted to play. She ran to the garden with her bucket, ready to have some fun.
Sarah filled her bucket with water from the pond, then she grabbed a pebble. She looked up at the sky and threw the pebble in the water. It made a huge splash!
"That was fun!" Sarah said with a smile. She filled her bucket up again, this time with more pebbles. She skipped around the pond and threw the pebbles in the water, one after the other. Each time, they made a big splash!
Sarah was getting hungry, so she ran back inside. She spread some delicious raspberry jam on her toast and enjoyed a yummy snack.
"What a nice day," Sarah said with a full tummy. Now she was ready to go back outside and make even more splashes!
<|endoftext|>
Mummy and Daddy were picking flowers in the garden. Mummy picked a red daisy, Daddy picked a purple thistle and the little girl picked a beautiful lily. The lily was her favorite because it was so fluffy and white and the aroma was heavenly.
Daddy said, "Let's bring this lily inside and put it on the windowsill."
Mummy said, "How about we make it a surprise?"
So the family all went inside and the little girl put the lily on the windowsill.
When she stepped back to admire her work, she noticed a bright yellow butterfly that had landed on the lily. The little girl smiled.
Mummy said, "Oh my, that lily looks so warm and cozy with the butterfly on top."
The little girl nodded, delighted with her surprise. And, from that day on, the warm lily became a happy reminder of the special family day.
<|endoftext|>
Once upon a time, there was a father and daughter. The little girl was very excited because her daddy was going to paint their house.
The daddy grabbed a paintbrush and a big tin of paint. He said to his daughter “Let’s go and paint the house!”
The little girl ran to get her toy axe. She said “I’ll help you, Daddy. I’ll use my axe to chop the wood.”
Daddy said “That’s a great idea! But you need to be careful because the axe is very sharp.”
The little girl got to work and chopped up some wood. She was careful and everything went well.
After they painted the house, Daddy said “Look how nice it looks now. Let’s go inside, it’s too hot outside.”
The little girl said “Yay! Daddy, you’re the best house painter!”
And everyone was happy. The End.
<|endoftext|>
Once upon a time, Lucy the bee was flying in the meadow. She was looking for a place to build her hive.
Suddenly, she saw a small, hairy bush. She flew over to take a closer look and saw that it was perfect!
"I'll make my home here," she said happily. She started to gather pieces of wood and flowers to build her hive.
Just then, a butterfly flew by. "What are you doing?" asked the butterfly.
"I'm building my home," Lucy said.
The butterfly smiled. "That's very nice," he said. "But what if something happens to it?"
"I don't know," Lucy said, frowning.
The butterfly nodded. "That's why it's important to build your hive with friends," he said. "If something happens, everyone can help."
Lucy smiled, and set to work with her new friends. After much hard work, they managed to finish the hive together.
The moral of this story is that it is always better to work with friends. That way, if something happens, we can help each other out.
<|endoftext|>
It was a beautiful day and Little Joe wanted to go for a walk. He quickly put on his shoes and ran outside.
On the grass, he saw a big hole. Little Joe was curious, so he slowly approached the hole. As soon as he reached it, he noticed something moving inside.
Little Joe said, “Hello? Who’s there?”
A little voice replied, “It’s me. I’m Mrs. Mouse. I’m stuck in this hole and I can’t get out.”
Little Joe was nosy and he wanted to help Mrs. Mouse. He said, “I’m going to catch you so you can get free.”
Mrs. Mouse was very thankful and together she and Little Joe were able to get her out of the hole. Mrs. Mouse was happy to go back home.
Little Joe was glad he was able to help her. He waved goodbye and went back home with a smile on his face.
<|endoftext|>
Once there was a man that had a dirty wet shirt. He was keen to wear it to a special event, so he put it on.
Unfortunately the shirt was too big for him! He went to ask his friend for help.
“Can you help me shrink my shirt?” he asked.
His friend smiled and said, “Yes. Put it in the dryer and let it spin around for a few minutes. Then it should be a better fit!”
The man thanked his friend and did as he said. He put his wet and dirty shirt into the dryer and watched it spin.
When the shirt came out it looked much better. It had shrunk enough so that it fit him perfectly!
The man was really happy and he wore his shirt to the event. He looked very smart and he was delighted with his new look.
<|endoftext|>
Once upon a time there were two friends called Winnie and Peter. They were both three years old and loved playing together everyday.
One day, as they were playing together, Winnie saw a trumpet lying on the ground and decided to grab it. She sat on it happily, not knowing what it was.
"Peter, come and sit too!" she shouted.
But Peter said he couldn't because it would be too rough.
Like a tornado, Winnie put the trumpet down and got off it - shocked. She had realised that the trumpet belonged to somebody else and she was sorry for trying to take it.
Although Winnie felt sad and guilty, Peter gave her a big hug and said "It doesn't matter what happened. Just be kind and honest to everyone. That's the most important lesson we can ever learn!".
The two of them shared one last hug and went back to playing together happily ever after. The moral of the story is to always be kind and honest to everyone.
<|endoftext|>
The sun was shining brightly in the sky, and Jack was running, because he wanted to go fast. He wanted to speed away across the grass. His mum, who was watching from the side, said, “Jack, careful now, you don’t want to trip!” Jack stopped and looked to the left. He saw a shy rabbit, hiding in a bush.
“Mum, look!” Jack shouted. He wanted to go over and meet the shy little rabbit.
But his mum said, “Jack, don’t go too close. We don’t want to scare it away. Let’s just watch it from here.”
So they both stayed very still and watched the rabbit, who stayed very shy and stayed in the same spot. Eventually, after a few minutes, the rabbit hopped away and disappeared. So they waved goodbye and Jack started running again. He sped off across the grass and his mum smiled.
<|endoftext|>
Once upon a time, Jane was walking through the forest. Suddenly, she saw a skull in the grass. It looked messy, like someone had been digging around.
"Hmm... What does this skull taste like?", Jane wondered. She bent down, grabbed the skull and carefully licked the bone. It tasted salty and sour at the same time.
Jane continued her walk, thinking about the skull. She knew she shouldn't have tasted it. Suddenly, a voice said "Why did you taste the skull?".
It was a small creature with red wings. "It looked interesting so I thought I'd try it", Jane replied. "That was a very wrong thing to do," said the creature. "Skulls are not meant to be tasted."
Jane agreed, suddenly feeling embarrassed. "I'm sorry," she said. "I won't do it again." The creature smiled, flew away and disappeared into the forest.
From then on, Jane was careful not to taste any messy skulls she found in the forest!
<|endoftext|>
Once upon a time, there were two friends named Lily and Max. They were playing in the garden outside of Lily's house. Lily's garden was so rich and colorful, with big green trees and red, yellow, and orange flowers.
Max looked around and noticed something. He asked Lily, "Do you recognize that thing in the garden?" Lily wasn't sure what he was talking about. Max pointed to a spot in the garden and said, "That big yellow thing is special."
Lily walked closer and then she recognized it! It was a huge yellow butterfly! She said, "Wow! It looks so pretty." The butterfly flew over to a nearby flower and started to drink the nectar.
Max and Lily watched the butterfly for a long time. Eventually, the butterfly flew away but Max and Lily never forgot about it. They will always remember their special moment in the rich garden.
<|endoftext|>
Once upon a time there was a hairy monster who lived under a mountain. The monster was so naughty that the other animals were scared of him. One day, the monster wanted to escape from the mountain, so he bit through the stone walls. Suddenly, a jail appeared in front of him. The monster was so scared that he forgot about freedom and ran back inside the mountain.
The next day, the monster saw a mouse walking by. The monster jumped out and said, "Please, mouse, will you help me escape this jail?"
The mouse replied, "If you promise not to bite me, I will try to help you."
The monster agreed and the mouse guided him out of the jail and back to the mountain. From then on, the monster was careful not to bite anyone anymore.
<|endoftext|>
Once upon a time there were two best friends named Tim and Jack. They had been friends since they were little and always looked out for each other.
One day, Jack got the exciting news that he had been accepted to the university of his dreams. He was so excited to get started on this new adventure. He told Tim the good news with glee, but Tim didn't seem as excited.
"Why aren't you happy for me?" asked Jack.
Tim sighed and replied, "I'm happy for you, but I'm also sad. We will be separated now that you're going away. I don't want that to happen!"
Jack smiled and said, "That's okay, we will stay in touch and be best friends forever. Just because I'm going to the university, doesn't mean you and I can't still have a chat when we are feeling a bit messy."
Tim smiled, happy to know that his best friend would still be around even if they were separated. They gave each other a hug and promised to keep in touch.
The moral of the story is that even when apart, you can still stay close to your friends if you remember to stay connected.
<|endoftext|>
One day, a small boy called Sam found a kite in the park. He was so happy to see it! He ran to get it and started to fly it.
Suddenly, an old man came over and told him, "Stop! You're disturbing me!" Sam was so scared.
The old man had a very gentle voice. He said, "This kite belongs to me. I lost it a long time ago." Sam was sorry to hear this and apologised to the old man.
The old man was very compassionate. He said, "I'm happy that you found it. Do you want to keep the kite? You can fly it whenever you want".
Sam was overjoyed that the old man was so kind. He thanked him a hundred times and flew away with the kite. He had a wonderful time in the park, flying his kite with a compassionate old man.
<|endoftext|>
Once upon a time, there was a group of yellow chickens on a farm. Every morning they would run around, looking for things to eat and play. One day, they found something even better - a basket filled with delicious grass and seeds.
The chickens were so excited! They took some of the grass and seeds back to the barn to share with their friends. The chickens started to prepare the food and made a big, tasty feast.
The chickens were all so happy, they decided to have a party. They danced around and sang cheerful songs all day.
Suddenly, one of the chickens noticed something in the corner of the barn. It was a giant yellow egg!
The chicken ran to get the others and said, “Let’s prepare the egg! We can share it with the rest of the group!”
The chickens worked quickly and soon had the egg ready for their friends. Everyone lined up and sang a happy song as they savored the delicious meal.
The yellow chickens enjoyed their party and danced until the sun went down. They ended the day with happy bellies and smiles on their faces!
<|endoftext|>
Once upon a time there was a truck. It was big and yellow and it liked to go out for rides. One day, the truck was driving down the road and it saw a little girl. She was very polite.
The truck stopped and said, "Hello there, I'm truck! Would you like to take a ride?"
The little girl nodded with excitement.
The truck said, "Let's go look around the town. I think you'll like it!"
The little girl smiled and said, "Thank you, Truck! That sounds like fun!"
They drove around the town and the truck pointed out lots of interesting things to the girl. They even stopped for ice cream.
When the ride was over, the little girl said, "Thank you for the ride, Truck. That was so much fun!"
The truck smiled and answered, "You're most welcome. It was my pleasure."
The little girl and truck waved goodbye, and the truck drove off down the road.
<|endoftext|>
Once upon a time, there was a little girl named Lucy. She was only three years old. She loved playing outside in the sunshine and running around with her furry cat.
One day, she noticed a big hairy stack of hay in the corner of her garden. She got really excited and rushed over to it. She ran her fingers through the soft hay and shouted with joy.
Then, she decided to make a hideout in the stack. She carefully moved the hay to create little nooks and crannies, and a cozy hiding place. She was so excited when she was done and couldn't wait to go hide inside her hay stack.
Just then, her cat came over and meowed. Lucy called out, "Hi kitty! I made a stack house. Do you want to come inside and play?" The cat darted inside, and Lucy quickly followed. She was so excited to explore her new secret hideaway.
The two of them curled up together in the cozy hay and stayed there for hours, filled with excitement.
<|endoftext|>
There was a boy called Will. He loved to play outside. One day, he found a wagon and he thought it was his. He was so excited and he said to himself, "It belongs to me now."
Will took the wagon with him to the park. He was having fun playing and pushing the wagon. Suddenly, a big boy came running towards Will. The big boy said, "That's my wagon. Give it back!"
Will was scared, but he said, "No! It belongs to me."
The big boy was getting angry. He shouted, "Stupid boy! You don't belong here!" He grabbed the wagon and ran away. Will was so sad. He learned that not everything he wanted belonged to him.
<|endoftext|>
One sunny day, a pirate was wandering through the woods. He had a big, shining hat, two swords and a wooden leg. Suddenly he heard a noise coming from the bushes. The pirate stopped and listened carefully.
"Ouch, it hurts", a small voice called out from the bushes.
The pirate went to investigate, and he saw a little girl, who was crying. The pirate asked her why she was crying, but she only shook her head.
The pirate lifted the little girl out of the bushes, and asked her again why she was so hurt. This time she told the pirate that she had been playing hide-and-seek with her friend, and had gotten lost.
The pirate put his arm around the little girl, and smiled down at her. He promised he would lead her home, so she wouldn't be hurt anymore. As the two walked, the pirate told her stories about his adventures of sailing the seven seas.
The pirate took the little girl home, and stayed to make sure she was safe. Both the little girl and the pirate were happy about this. The little girl had learned an important lesson - always listen to your parents, so you don't get lost. And the pirate had learned a lesson too - helping out others can make you feel good.
<|endoftext|>
John ran quickly to the mall. As he looked around, he saw so many things. He found a deep pond with lots of fish inside.
“Wow,” John said.
John saw Mommy walking up to him. “Hi John!” she said. “Let’s go on a hunt. Can you help me find something?”
“Sure!” said John. The two of them ran around the mall looking for things. They saw a big deep bird's nest in a tree. They also saw lots of yummy snacks in the mall store.
John saw a playground and got excited. “Mommy, can we go on the slide?” he asked.
Mommy laughed. “Of course!” She said. They ran to the slide, and soon they were having lots of fun. After a while, it was time to leave. John said goodbye to all the friends he made and ran back home.
<|endoftext|>
Once there was an infant playing in a garden. He was with his mom and dad. The infant looked around, examining the colourful flowers and plants. He noticed another infant in the garden who was also playing.
The two infants said hi to each other and quickly became friends. They laughed and talked about how helpful their parents were.
Together, they explored the garden. The little friends looked at all sorts of things, some furry, some wet and some slimy! Suddenly, they heard a loud noise coming from above.
They looked up to see a big dark cloud. The cloud was growing bigger and bigger. Then, the two infants heard their parents calling them. The infant told his friend he had to go, but promised to make up for it.
Unfortunately, the infant never got to see his friend again. When he returned to the garden later, he saw a big storm had destroyed the garden. He said goodbye to his friend in his heart, knowing he'd never see him again.
<|endoftext|>
Once upon a time, there was a little girl named Molly. Molly had a great big, hairy dog. They were very happy together.
One day, Molly and her dog were out walking in the park when they heard a noise. Molly was scared and she hugged her dog tight. Then something strange happened. A ghost appeared beneath a tree. It was a very strange sight.
Molly's dog growled at the ghost. The ghost ran away and Molly felt brave.
"What was that, Molly?" asked her dog.
"I don't know," replied Molly.
As they continued their walk, Molly noticed something strange. Whenever Molly said the word "yield", ghosts appeared from the trees! She had the magic power to make ghosts yield.
Molly was excited and scared at the same time. She decided to keep this magic to herself. Molly went home and hugged her hairy dog. She knew she was safe.
<|endoftext|>
Ted was a lively little boy. He was always ready for adventure. One day Ted found a shiny red helmet and he couldn't resist trying it on. He wore it everywhere and loved it.
One day, Ted and his friends decided to go biking. Ted proudly put his red helmet on, and prepared to go. Suddenly, his helmet began to tear. Ted's friends laughed.
"Oh Ted, what shall you do now?" one of them asked.
Ted smiled and said: "I don't need a helmet to go biking. I'm too lively for danger!"
Everyone agreed and went off on their bicycles, happily racing each other. Ted was the happiest of all.
<|endoftext|>
Once upon a time there was a puppy. He was small and brown, and loved to play. Every day, he would go out on fun adventures with his dad.
But one day, something wonderful happened! His dad decided that he was an obedient dog, so he was going to become a model! That meant he had to listen even more closely to his dad, so he did his best.
The puppy was so excited to model for all the people he met. He loved meeting new people and showing off how obedient he could be. People would say, "What a nice puppy!"
The puppy soon became famous! He was very popular, and his dad was so proud of him. The puppy had become a very famous model!
The puppy and his dad had lots of fun after that. The puppy was always very obedient, which made his dad very happy. They would go on all kinds of adventures and the puppy was always the star!
<|endoftext|>
Once upon a time, there was a little girl called Claire. She was very brave and powerful. One day, she was playing in her yard when she saw a patient sitting on the grass. The patient was crying and seemed very sad. She went over to the patient and asked, "What's wrong?"
The patient told Claire that she had fallen from her bed earlier that day. Claire was determined to help the patient, so she put her powerful hands on the patient's back and tried to lift them off the ground. But the patient was too heavy.
Claire thought and thought. She decided that the only way she could help the patient was to get help from her mom and dad. She ran into her home and called her parents. Then they all helped the patient back onto her bed.
The patient thanked Claire and said, "You are a very brave and powerful girl!" Claire smiled. She was happy she was able to help.
<|endoftext|>
Once upon a time, there was a little girl who loved playing with her doll. Her doll was the best in the whole wide world. Every day, she would take the doll out of its box and admire the bright eyes and soft hair.
One day, the little girl saw a beautiful rug in the living room. The rug was pink and had soft, white flecks. She went over to admire it, but then she felt shy.
“Why are you feeling shy?” asked her mom. “It’s just a rug!”
The little girl sheepishly smiled and said, “I’m shy because I don’t know how to admire a rug like I do my doll.”
Her mom smiled. “You can admire it in the same way – look at its colors and its texture. It will look just as beautiful!”
The little girl smiled and got a bit closer to the rug. She admired its softness and the way it glowed in the sunlight. She felt happy and knew she could admire anything if she used her imagination.
<|endoftext|>
Once upon a time, there was a little girl. She had a black candle in her hand. She said, "Let's go and rest!" The little girl set her black candle down and flopped on the bed. When she closed her eyes, she heard a voice. The voice said, "Don't forget me!" The little girl opened her eyes and picked up the black candle. She said, "Let's go and rest together!" So, the little girl and the black candle went outside and found a nice spot to sit and rest.
The little girl held the black candle close and said, "Thank you for coming with me to rest." The black candle glowed and replied, "You're welcome, my friend." Then the sun began to set, and the little girl and the black candle watched the sky turn from blue to black. They rested for a few more minutes before the little girl stood up, blew out the black candle, and said, "Let's go home now."
And so, the little girl and the black candle went home together and had a good night's rest.
<|endoftext|>
Once upon a time, there was a little boy named Andy. He loved to explore and watch the world around him. Everywhere he went, Andy was curious and wanted to know more.
One day, Andy saw an interesting clock. He was very curious and asked his mom, "What's that?"
His mom smiled and said, “That’s a clock. It tells us what time it is. See, it's twelve o'clock.”
Andy was amazed and said, "It can really do that? Wow, this clock is so cool!"
From then on, Andy looked at the clock every day to see what time it was. He was always a bit surprised when he saw the hands moving around and around. Everywhere he went, Andy was curious and wanted to know more.
<|endoftext|>
Once upon a time there were two friends, Emma and Jack. They went to the market together to see what they could find. While they walked around, Jack saw something very attractive.
"What do you have there?" Emma asked.
"Oh, just something I found." Jack said, holding it up for Emma to see.
"That's really nice, can I take a closer look?"
Jack said, "Sure, it's yours if you want it. We can do a trade."
So, Emma and Jack talked about what kind of trade they would do. Emma said she had some ribbon that was really pretty and Jack said he wanted something useful. So they decided Emma would give Jack the ribbon and Jack would give Emma the thing he had found. They both thought it was a good trade.
At the end, they both smiled and thanked each other. They hugged and said goodbye. Emma went away with her new thing and Jack went away with a ribbon. It was a good day at the market!
<|endoftext|>
One day, Ginger was playing with her little brother in the playground. Although she was only three years old, she wanted to show off her skills.
She climbed a ladder that was much too big for her and once she reached the top she proudly shouted to her little brother, “I am winning!”
Her brother was very proud of her, but he wished he could do the same. He asked, “Can I win too?”
Ginger laughed, “Of course you can win! But you have to be very brave and try your hardest.”
So Ginger helped her brother to climb the ladder. He was a bit scared, but his sister was there encouraging him. Finally, he made it to the top and shouted in triumph, “I won!”
Ginger hugged her little brother, “That’s the way to be true and win!”
They looked around and saw that the playground was very dirty. Ginger and her brother quickly got to work cleaning it up.
Ginger smiled at her brother, “Winning is even more fun when it’s true and clean!”
<|endoftext|>
Once upon a time, there was a small girl. She had a curious mind and liked to explore the world. One day, she was playing in her garden when she noticed a tall hedge. It was big and blue and it seemed like it was hiding something.
The girl wanted to know what was behind the hedge so she started searching for a key to unlock it. After searching for a little while, she found a tiny blue key in the dirt. She was so excited that she ran to the hedgewit the key in her hand.
The girl tried the key in the hedge but it didn't fit. She felt a bit sad but decided to keep searching for something that could open it. After a while, she found a small hole near the bottom of the hedge. She carefully inserted the key into the hole and - click! - the hedge opened.
Behind the hedge was a secret garden filled with beautiful blue flowers. The girl was so happy! She couldn't believe that something so beautiful was hidden behind the hedge. She was excited to explore the secret garden and kept visiting it every day.
This is how the small girl discovered the secret garden and every time she visited it, her joy was even bigger than before.
<|endoftext|>
Once there was a modest pilot who flew a plane each and every day. One day, a loud siren rang from his plane. He had no choice but to put on the parachute and save himself.
The pilot looked down from the sky and saw a river below. He threw away his fear of water and jumped into the river. He was relieved to see a small rowboat at the side.
The pilot started rowing with all his might and for hours and hours, he continued to row. Suddenly, he heard a voice from the river bank. It was a three year old child.
"Where are you going?" the child asked.
The pilot answered, "I'm trying to save myself."
The child smiled and said, "I can help you! I have a bigger boat at home."
The pilot thanked the child and soon they were on the bigger boat. After several hours, the pilot reached the shore safely.
He thanked the child and said, “I’m very lucky to have found you. You saved my life.”
The modest pilot was very grateful for the child's help.
<|endoftext|>
The curtains were hanging cleanly in the windows of the little room. Every day, the girl would run in and whisper secrets to them. She hadn't noticed it before, but today, when she was talking in her very quietest voice, the curtains rustled as if in response. Her eyes grew wider as she heard what sounded like an echo of her own whisper.
Curious, she asked the curtains, "Can you understand me?". The curtains didn't move. She whispered the question again and waited. She heard a faint whispering in response, but it wasn't the same as if she were speaking. This whisper felt different somehow.
The girl waited and listened. Suddenly, the curtains moved again. This time they were pushing back, inviting her closer. As the girl looked closer, she saw a crack in the window and she could now hear more clearly the voice she had heard earlier. "Come here," it said.
The girl took a deep breath, trembling with anticipation and excitement. She stepped closer and the curtain parted. Behind it was a secret garden. Everything was clean and vibrant and the girl felt more alive than she had ever felt before. She was finally on an adventure of her own.
The girl and the whisper from the curtains had a lot more to share.
<|endoftext|>
Freddy the teddy was feeling very lonely. He wanted a friend to play with. One day he went for a walk and he rolled past a big house.
When he got to the doorstep, he heard a voice.
"Hello? Who's there?" The voice said from behind the door.
Freddy was so surprised. He looked around and saw a big brown curtain was pulled aside. He saw a friendly face waving at him. It was a small girl.
"Hey! I'm Suzy! Who are you?" Suzy asked with a big smile.
"I'm Freddy the teddy" Freddy replied with a smile too.
Suzy brought Freddy inside and they started to play together. They rolled around the house laughing and having fun with each other.
Freddy was so happy to have a new friend to play with. And every day they opened the big brown curtain and made new adventures together.
<|endoftext|>
One day, Mommy and Little Man were in the park. Little Man was hungry and Mommy gave him a spoon. Little Man excitedly started walking and he saw a dangerous-looking bee. He ran up to Mommy and said, "Mommy, Mommy! Bee!" Mommy looked and said, "Yes, honey. That bee looks dangerous." Little Man said, "Can I accept it?" Mommy smiled and said, "No, sweetie, we can't accept it. It's too dangerous." Little Man looked down and frowned. Just then a butterfly flew by. Mommy said, "Look, Little Man. That butterfly isn't dangerous. You can accept it." Little Man smiled, excitedly accepted the butterfly, and ran off with his spoon.
<|endoftext|>
Once upon a time there was a three year old girl named Lily. She was playing with her favorite toy when suddenly she heard a loud noise.
Lily was afraid so she ran and hid behind the dining room table. Then she heard a voice coming from the kitchen. It was her mommy.
"Lily, stay here and don’t move! I’m going in for an operation tomorrow and I need you to be a brave girl", said Mommy.
Lily was very scared but she nodded her head. Then her mommy hugged her tightly and said, "Don’t worry, Mommy will be okay. The doctors will take care of me".
Then Lily’s brother, Jack, came into the room. He was being selfish and wanted attention. He said, "Why does Lily get all the hugs? What about me?".
Mommy smiled and said, "I love you both the same. Just sit next to Lily and I’ll hug you both".
So Lily and Jack stayed there, cuddled up together and Mommy hugged them both.
<|endoftext|>
Once upon a time, there was a little girl named Jane. Jane wanted some rice for dinner. She asked her mom, "Mom, can I have some rice for dinner?"
Her mom smiled and said, "Of course, Jane. You just have to be patient."
So Jane waited patiently while her mom cooked the rice. When it was ready, Jane ate some of it, but she was so full, she fell asleep while eating her rice!
Her mom came over and carefully picked up Jane. She carried her to bed and tucked her in. Jane was so tired she went straight to sleep.
Mom smiled and said, "Jane, you should take a good nap so you're ready for school tomorrow."
Jane happily snuggled into her blankets and went to sleep, dreaming about the delicious rice she had for dinner.
<|endoftext|>
Once upon a time there was a little girl called Daisy. Every day she would ask her parents to teach her new things.
One day, Daisy saw a model car on the table and asked her mum to teach her about it. Daisy's mum said she would, but first Daisy had to do her chores. Daisy was sad, but she agreed and finished her chores.
Once the chores were done, Daisy's mum taught her all about the model car. She showed her how to put it together and all the amazing features it had. Daisy was very happy and she was proud of the model car she had made.
The next day, Daisy and her mum went to the park. Daisy wanted to show everyone her model car, but when she got to the park she saw another girl playing with an even bigger and more amazing model car than hers. Daisy became very sad, she wished she could have that car too.
But then Daisy's mum came up with an idea. She said "Maybe I can teach you how to make a bigger and more amazing model car". Daisy was very excited and thanked her mum for the offer! Daisy's mum taught her all she needed to know and Daisy became the proud owner of a bigger and better model car.
<|endoftext|>
Tommy was playing in the park with his new helicopter. He was very excited. His papa had given it to him for his birthday.
Tommy was pretending to fly the helicopter around the park. He pretended it was the real thing. Suddenly, a mean boy came up to him.
The mean boy said, "That's a fake helicopter. Give it to me!"
Tommy screamed and held the helicopter close. He said, "No! It's mine! I won't give it to you!"
The mean boy got mad and tried to grab the helicopter. But Tommy was too quick. He threw the helicopter as far away as he could.
The mean boy chased the helicopter, but Tommy ran the other way. He was safe now. After that day, Tommy never saw the mean boy again. He would always play with his helicopter in the park.
<|endoftext|>
Once there was a little girl named June who loved to drive. She had a beautiful car that was blue and silver and she loved it very much. One day, June wanted to drive to hear her favorite band play.
June asked her mom, “Can I drive to the band?”
Mom said, “Yes, June. Be careful!”
June was so happy and put on her seat belt. Then, she started her car and drove down the street.
The band finished playing just before June arrived. Everyone was saying how beautiful the music was. June clapped and smiled.
The band thanked everyone and waved goodbye. June waved back and drove home.
That was the day June went to see her favorite band!
<|endoftext|>
Mia was playing outside in the enormous park. She could see so many things. There were trees, and rocks, and slides. She wanted to slide, but it was too high for her.
Suddenly, she heard a loud noise. Mia turned around and saw a giant striking the ground very hard. Mia was scared and hid behind a tree.
The giant noticed her and said, "Hello Mia". Mia was so surprised that he knew her name. The giant asked, "Do you want to play with me?" Mia thought for a moment and said, "Yes, I would like that."
So Mia and the giant played a game together. They rolled rocks, laughed and had fun! After a while, the giant struck the ground with his foot and said goodbye.
Mia waved goodbye to the giant and couldn't believe he was so enormous and friendly!
<|endoftext|>
Linda was walking in the forest when she saw something mysterious. She had to take a closer look. She slowly approached it, and realized it was a bulb. She was very excited, she wanted to grab it, and take it with her.
Suddenly a voice shouted, "Hey! Don't grab it!" Linda jumped back in shock. A mysterious figure was standing there, she had never seen anything like it before. He asked her, "Do you know what this is?".
She shook her head, and he said, "That to me is a precious bulb. It's not an ordinary bulb, you know, it can perform magical tricks". Linda's eyes lit up with curiosity, she couldn't take her eyes off it.
The figure said, "If you want, You can take it with you". Linda was very excited, she grabbed the bulb and hugged it. She thanked the figure and ran home. She knew this was going to be a fun adventure.
At home, Linda started exploring the bulb. She played with it and tried to figure out how to make it work. She closed her eyes, concentrated and presto! The bulb suddenly glowed and started performing magical tricks! Linda was amazed, she had never before seen something so mysterious.
<|endoftext|>
Once there was a bird who lived in a forest. One day it wanted to fly, so it flapped its wings and rose high into the sky. Its wings were strong and it felt so free.
But then it started to feel something strange, a thick, dark ash was filling the air. What was it? The bird wondered.
Suddenly it heard a voice from down below.
"Haha!" Someone laughed, "that's my fire! I burnt it bigger and stronger, so the ash would fly!"
The bird flew down to see what was happening. It saw a small figure standing by a campfire.
The bird asked, "Why do you want the ash to fly?"
"Because," the figure replied, "when it floats across the land, it makes things more bitter for the people who live here. That's why I like to make my fire bigger and stronger."
The bird was shocked. It didn't want anyone to be made miserable like that. It flew back up into the sky and spread its wings wide, creating a gust of wind. This blew the ashes away, removing any bitter taste they might bring.
The figure watched in amazement as this kindness of the bird.
The bird said before it flew away, "Don't ever forget that kindness can spread hope and joy, even in the darkest of places."
<|endoftext|>
Once upon a time, there was a clean picnic in the park. Two kids, one called Ben and the other called Lucy, were excited to eat their lunch.
Ben said, "Let's close the picnic basket so no bugs come in". He shut the lid and the two kids sat on a blanket. They started to munch on their food, but soon heard a loud buzzing noise.
Lucy said, "That's strange! What is that noise?" She looked around and saw a bee flying above them. Ben said, "We should have kept the picnic basket closed!" They started to run away, but Ben quickly realized he left the blanket on the ground.
Ben felt that they must go back, but Lucy refused. She thought the bee would still be around. Ben said, "We have to go back, otherwise the blanket will get dirty!" Finally, they ran back and quickly grabbed the blanket.
The two kids laughed as they ran away with the blanket. They learned an important lesson that day - to always keep their picnic basket closed!
<|endoftext|>
Once there was a mommy and a toddler. The toddler wanted to try to do yoga with mommy. So they tried it together.
The toddler tried to touch his toes, but he could not do it. He felt frustrated. Mommy said, "Stretch your legs, sweetheart. You can do it!"
The little one tried again and he actually got his toes to touch. He felt proud and happy, but it still seemed like a long way for him to do yoga. The mommy held his hand and said, "Let's take it slow, and practice often."
The toddler and mommy kept practicing yoga and soon, the little one could do long stretches. He smiled and told mommy, "Look what I can do now!"
The moral of the story is that practice and patience can help us do anything, even if it seems too hard or too long in the beginning.
<|endoftext|>
Once upon a time, there was a deaf, three year old girl. She loved going to the library every day and read books.
One day, while she was reading, she came across a big book about history. She was curious and wanted to read it, even though she was scared of its size.
The librarian saw the girl and smiled. She said, “Do you want to read more about history?” The girl nodded and the librarian said, “That’s great! You can learn so much from reading history books.”
The girl smiled and took the book home. She read the book every day, and soon she knew a lot of facts about the past.
The girl was very proud when she showed her parents what she had learnt from reading history. Her parents smiled and said, “You’re so clever!” She felt so proud - she had achieved something all by herself, even though she was deaf!
<|endoftext|>
Once upon a time, there was a girl called Lucy. She was very small, only three years old, and sometimes felt helpless. Lucy wanted to explore the world, so one day she decided to wander.
She went far from home and eventually stumbled upon a weird stage. On the stage was an old man who saw Lucy and asked her if she wanted to join him. She nodded, filled with excitement about what she would see.
The old man put on a show, but Lucy didn't understand one bit of it. She became frustrated and started to cry and told the old man that she wanted to go home. He laughed and continued the show.
Lucy felt helpless and didn't know what to do. Suddenly, a woman walked on to the stage and said to the old man, "Let the little girl go. She's too young to understand what you are doing."
The old man gave a funny smile and nodded. He said to Lucy, "You can go home now - remember never to wander too far again." Lucy smiled and wandered back home, feeling a little wiser.
<|endoftext|>
Once there was a panda who was very hairy. He was called Andy. Every day, Andy would go and search for food.
One day, he was walking deep in the forest when he saw a small cave. He thought it would be a great place to look for food. As he got closer, he could feel the cave was strange.
When he stepped inside, he saw there were many white things on the ground. He didn't know what they were, but he knew he needed them.
Andy walked around the cave carefully and eventually found a big pile of bamboo. He was so happy and wasted no time picking up as much as he could.
Suddenly, he heard a voice. It said to him, "I need help. You need to help me". Andy looked around but he couldn't see anyone in the cave. With a puzzled look on his face, he said, "Who said that?".
The voice said, "I'm here. I am a big, hairy panda like you. I need your help to get out of the cave". Andy was so excited. He took the white things and placed them in a line in front of the cave. He said, "These will help us get out of here!".
Slowly, he and his new friend made their way out of the cave. Once they were safely outside, they hugged each other. They were so happy and thanked each other for
<|endoftext|>
Once upon a time there were two brothers named Billy and Joe. They both loved to explore the outdoors and always looked for adventure. One afternoon, they decided to take a walk in the woods.
Suddenly, something strange happenned. A glowing ball of light started to appear and floated above the trees. Billy and Joe were so amazed!
"We must catch it!" yelled Billy.
But each time the boys tried to get close to the ball, it would vanish! No matter how persistent they were, they were unable to catch it.
Eventually, they had to give up. Joe said, "Let's go home now, brother. We'll come back another day and search some more."
Billy and Joe happily returned home that morning, with an exciting secret to share.
<|endoftext|>
Danny was in a hurry. He wanted to get to the park quickly and he ran as fast as he could. His mama said they would be late if he didn't hurry up.
When they got to the park, Danny was eager to run and play. He didn't want to wait any longer. But his mama said he had to be patient. She told him that his friends were coming soon.
So Danny sat down on the bench to wait. He was patient, but it was hard. All he wanted was to play with his friends. He wished for them to hurry.
Suddenly Danny saw them running down the street. They were hurrying just like him. He couldn't wait any longer and ran to meet them. He was so eager to start playing with them.
Danny's mama smiled. She was glad that Danny had been so patient. Finally he could have fun with his friends.
<|endoftext|>
Once upon a time there was a girl who wanted to build something special. She had an idea to make a stack of blocks.
The girl went to get the blocks and found that some were regular ones and some were special ones.
She was excited and started creating the stack of blocks. She put the regular blocks on the bottom and then the special ones on the top.
Suddenly, the stack of blocks fell down. Oh no!
The girl was sad but she said, “I can fix this”.
Little by little, the girl put each block back in place. With a lot of hard work, she managed to make the stack look perfect again.
The girl was so proud. She shouted, “I fixed it!”
And the stack of blocks stayed standing.
<|endoftext|>
Once upon a time, in a small village there lived a young girl called Lucy. She was very popular among her friends for her vibrant and happy personality. One day, when Lucy was walking past the park, she spotted something in the grass. When she looked closer, she saw it was an old purse!
Lucy was so excited and she bent down to pick it up. When she opened the purse, she found lots of coins inside. She was so happy that she could now buy herself some new toys.
But when she tried to stand up again, Lucy suddenly realised that she was stuck. She had been using her purse to balance herself and in the process had become tangled up in the long grass.
Lucy started to struggle to try and get untangled, but the long grass was too powerful. She began to cry and shout for help.
Just then, one of her friends walking past the park heard her cries and came to her rescue.
Her friend put down his popular baseball cap and helped Lucy free herself. After a few minutes of struggling, Lucy was free. She thanked her friend and gave him a big hug.
The two of them stopped to count the coins inside the purse before walking back to Lucy's house.
The End!
<|endoftext|>
Once upon a time there was a boy called Tom. He was a very kind and gentle boy. He felt sad every day because sometimes it felt like the world was too rough and unkind.
One day Tom spoke to his mom and said, "Mom, I don't like that the world is so rough." His mom paused and thought for a moment, then said, "I know what you can do to help make the world nicer, Tom."
Tom waited eagerly as his mom explained. "You can use your kind heart to heal the world. You can be kind and gentle like you always are and that will help the world feel better." Tom's eyes lit up and he wondered if he could really do it.
The next day, Tom went outside and smiled at everyone he saw. He said hello and wished them a good day. Little by little, he felt more and more joy in his heart. He knew he was helping to heal the world and that made him smile.
The world always needs a little bit of love, and with help from Tom, it was slowly beginning to heal.
<|endoftext|>
Once upon a time there were two friends, Joe and Jenny. Joe and Jenny loved to play together outside. Today, they were playing at the beach.
The beach was clear and the sun was shining. Joe and Jenny saw some fish swimming in the sea. Jenny asked Joe: "Can we go swim?"
Joe hesitated. He said, "No, let's stay here". But Jenny said, "Please, Joe! Let's go swim!"
Joe finally agreed. He said, "Okay. But only if you stay close to me".
They went to the water and they paddled and splashed around. There were big waves, and it was a lot of fun.
But then Joe saw something. He saw a big fish that was coming right at Jenny! Joe was scared. He shouted, "Jenny, look out! Swim away!"
Jenny screamed and started swimming away quickly. Joe reached out and slapped the fish away.
Finally, after a lot of swimming, Joe and Jenny were safe. Jenny looked at Joe and said, "Thanks for saving me, Joe!"
Joe smiled and said, "I was just looking out for you".
<|endoftext|>
Frank the frog was very troubled. His fountain had broken and he was sure no one could fix it.
One day Frank's best friend Sam the snail came to visit him. Sam asked, "What's wrong Frank?"
Frank said sadly, "My fountain is broken and I can't fix it."
But Sam had a plan! He said, "If you come with me I might know someone who can help you fix your fountain."
So Frank and Sam went out into the woods, looking for help. And soon they found Snail Bob!
Snail Bob smiled at Frank and said, "Don't worry, with a bit of hard work we can get your fountain running again."
Frank was overjoyed! He and Snail Bob got to work and soon he had a beautiful working fountain.
Frank was so happy and relieved, and he thanked Snail Bob for his help. From then on, Frank and Sam made sure to visit Snail Bob to say thank you.
<|endoftext|>
Once upon a time there was a girl and her name was Sarah. Sarah loved to share her toys with her friends. One day she went upstairs to her bedroom, and she saw something beautiful. It was a magical castle with a gate that opened up to reveal a pink garden. Sarah couldn't believe her eyes! She called her friends to come upstairs and see what she had found. Her friends were amazed when they saw the beautiful castle. They all decided to share in the fun and explore the magical garden. They all had such a fun time that day playing in the castle and exploring the garden.
<|endoftext|>
Once upon a time there was a very wealthy family who owned many things, but the family's most cherished possession was the puppy that the father had bought for the children that same day. The puppy was small and fluffy with big, black eyes.
The family went outside to play with the puppy, and they laughed with joy as they watched the puppy chase around butterflies. Suddenly, the puppy started to shiver with cold and the family looked up to see storm clouds gathering in the sky.
The mother said to the father, "Let's go inside quick and get the pup warm." But the father said, "It's ok, the pup will be fine in this weather," and he began to walk away.
The children were about to shiver too, but the mother quickly picked up the puppy and rushed everyone inside to safety.
The family was so thankful that the mother had acted quickly and that the puppy was safe. The mom said to the dad, "See, that's why I always listen to my instincts." The family smiled and hugged their beloved puppy tight, thanking the mom for her wisdom.
<|endoftext|>
Once upon a time, there was a little girl named Jane. She was a very curious three-year-old who liked to explore. One day, she decided to go for a walk in the park.
On her way she saw a big hill. It looked fun, so Jane decided to take a few steps up it. It was easy, so she kept going and soon she was at the top!
Jane was so proud of herself. Just then she heard someone say, "Wow! You made it up here so quickly!"
Jane turned around and saw a tall man wearing a hat. She smiled and said, "Yes, I was going very fast!"
The man laughed and said, "You sure were! Great job!"
Jane thanked him and continued on her way. With a smile on her face, she knew she could do anything if she put her mind to it.
<|endoftext|>
Tim was feeling very nervous. He didn't like to talk in front of big crowds. Everyone was watching him and he felt scared. He just wanted to be alone and hide.
But Tim couldn't hide. He heard his mom calling him to talk in front of the crowd. He was so afraid that he started to cry. But he didn't want to look silly in front of everyone, so he wiped his tears away and slowly stepped forward.
He was shocked to see all the junk in the room. There were all sorts of broken toys and trash strewn about. He realized it was a junkyard, and he felt even more nervous. He wanted to go back home, but his mom was encouraging him forward.
He took a deep breath and slowly started to talk. At first it was hard, but soon the words were coming easier and he was no longer scared. He looked out over the crowd and he could tell they were listening.
When he was finished talking, there was a big cheer from the crowd. Tim couldn't believe it. He had done it and he was so proud. He looked back over the junkyard and smiled. He was no longer scared.
<|endoftext|>
Benny was at the airport with his mom. He watched as people moved around him with huge suitcases. They made careful steps with the big bags. Mom said, “ We need to pack your luggage Benny. It’s time to go home.”
Benny rolled his small suitcase to the desk. The lady behind the desk smiled at him and said carefully, “Now I need you to check your suitcase so we can get you on your flight.”
Benny stared at the little suitcase. He watched as the lady pressed some buttons and then it closed with a loud click. He felt a swell of excitement in his chest and jumped with joy.
Mom saw the excitement on Benny’s face and said with a smile, “Now it’s time to take that luggage and go home. Be careful and walk slowly, okay?” Benny nodded and carefully held his suitcase as he walked out of the airport. He was on his way home.
<|endoftext|>
Once upon a time, there was a delicate boat floating in the ocean. It was getting tired so it decided to take a rest. The boat gently floated to a beautiful harbor. The harbor was full of many boats like the delicate one. The delicate boat was happy to be in the harbor. All the boats rested in the harbor together. There was a nice breeze blowing. Everyone was happy and safe in the harbor. The delicate boat went to sleep in the harbor and felt cozy and content.
The boats stayed in the harbor for a long time to get some rest. After a while, the boats started to wake up and were ready to sail again. The delicate boat was happy to be in the harbor and thanked them all for the peace it had found.
The delicate boat was so happy that it had found a place to rest in the harbor. It said goodbye to the other boats and started sailing again. The delicate boat went on many adventures, but it would always remember the peaceful moments it had spent in the harbor.
<|endoftext|>
John was out at the park with his family. He wanted to act brave, so he ran and jumped across the wooden bridge. But when he reached the other side, he felt a bit dizzy. He decided to sit and watch his brothers and sisters play. He heard his dad say something about a surprise.
Mom asked, "What surprise, dad?"
Dad replied, "We'll give John a special pass that he can use to go on all the rides at the fair!"
John was so excited that he jumped off the bridge and ran over to his dad. "Can I go on the rides?" he squealed.
Dad smiled and said, "All in good time my son. You'll have to wait and see!"
All the way home, John wondered what it would be like to be able to go on all the rides. When they arrived home, he was so eager to find out that he ran inside and grabbed the pass. But as he looked at it, he felt a bit dizzy. It was only then that he realized it had to be a special day to use the pass. Now he was more excited than ever to find out what it was!
<|endoftext|>
Once upon a time, there lived a little girl. She had a special mission; to collect doves. Everyday she would put on her brightly coloured dress and her sparkly shoes and go out collecting. Every morning she would walk to the park and then look to the sky. Then she would spot a dove and try to catch it in her hands.
Today was a sunny day, and the little girl was feeling very sleepy. She found a big tree to sit under as she watched the doves up in the sky. Suddenly she noticed a dove land on a branch close to her. Gently, she reached out to try and catch it. "Coo-Coo!" the dove said.
The little girl was suprised. She had never heard a dove talk before!
"Hi, little dove" the little girl said. "My name's Daisy. And I'm here to collect doves".
"Well, you caught me!" the dove said. "Let's be friends!"
Daisy was so happy. She had found a special friend and could share her dove collecting mission with him.
Together Daisy and her dove friend went on many adventures and caught lots of doves. Every night before bedtime, Daisy would give her doves a big hug before they flew up to the sky.
That was Daisy's life collecting her special doves, and it was just perfect.
<|endoftext|>
Once upon a time there were two friends, Jack and Jill. They liked to play together every day in the park.
One day, Jack wanted to eat beef for his lunch. But Jill wanted to eat something else.
Jack said to Jill, "Let's eat beef, it's yummy!"
Jill said, "No, I want to eat something pink."
Jack was not happy and they started to play a game of tag. Suddenly, Jack had an idea. He said, "Let's go to the store and buy a pink beef!"
Jill was excited and they ran to the store. They found a delicious pink beef, and Jack bought it for Jill. Jill was so happy, and they both enjoyed eating the pink beef together.
The friends kept playing in the park and enjoyed their lunch of pink beef. From that day on, Jack and Jill enjoyed playing together and eating pink beef for lunch.
<|endoftext|>
Once upon a time, there was a small, weak girl. One day, she went on an adventure and went to the beach. On the beach, she saw the ocean, which was big and blue. She waved to it and wondered what kind of dreams it could have. Suddenly, she felt brave and decided to dip her feet into the ocean water. The water was cold and tickled her feet. She liked it and wished she could stay there forever.
When it got dark, the girl went back home. She looked up at the stars and thought about how small she was compared to the universe. Then, she remembered the dream she wanted to take from the ocean. She imagined it was a dream that could make her strong, and she held onto it tight.
The next day, she took a deep breath and waved goodbye to the ocean. She felt weak but strong in her heart. She knew that no matter how hard things got, her dream would give her the courage she needed to keep going.
<|endoftext|>
The sun shone brightly in the jungle that day. Bob the monkey was sad. He watched the other animals in the jungle playing together. He wanted to join in the fun, but nobody asked him to play.
Suddenly, an elephant stomped into the clearing and roared. He was mad! Everyone else looked scared. The elephant turned to Bob and said, "You need to help me find my lost trunk!"
Bob didn't want to help, but he knew he had to. He climbed onto the elephant's back and off they went. But when the elephant couldn't find his trunk, he got even madder! He turned to Bob and slapped him with his trunk.
Bob ran off, never to be seen in the jungle again. He was sad. He wished someone had played with him when he had the chance.
<|endoftext|>
Once upon a time, there was a little boy named Jack. Jack was a happy and active child who loved to play around wherever he went.
Today, Jack was feeling very tired so he decided to take a nap. He found a big tree and he decided to take a stand underneath it. He snuggled up to the trunk and closed his eyes.
As Jack was sleeping, he felt something touch his arm. He opened his eyes and saw a butterfly looking at him. "Hello," said Jack, rubbing the sleep from his eyes.
The butterfly said nothing and continued to touch Jack's arm. It felt so soft that Jack smiled and nodded his head in agreement.
The butterfly flew away and Jack slowly got up and stretched his legs. He felt much better and much less tired.
Jack smiled and said thank you to the butterfly before he went off to play.
<|endoftext|>
Fred was a robot who lived on a planet far away. He loved to go on adventures and one day he wanted to explore. He put on his running shoes and began to jog. He thought it would be a nice day for running.
As he jogged, he looked up at the sky and saw an enormous planet. It was so big and sparkly that he wanted to go and see it. Fred ran even faster and eventually he got to the enormous planet.
When he arrived, he felt so excited! He wanted to explore the planet. He looked around and said, “Hello? Anyone home?” Suddenly, he heard a voice from the sky. “Hi Fred, I’m here!” Fred looked up and saw a giant smiling at him. The giant said, “Welcome to my planet – let’s explore together!”
Fred and the giant had a wonderful time exploring the enormous planet. They ran and jogged around the planet, discovering new things and having great adventures. Fred was so happy and grateful to have found this amazing planet. He couldn’t wait to come back and explore it again!
<|endoftext|>
Once upon a time there was a boy called Tom. Tom liked to play outside but sometimes he got tired and wanted to rest. One day, Tom was sitting in his garden and saw something he wanted - a nice, red stamp. It was beautiful and Tom knew he needed it.
So Tom asked his mum, “Mummy, I need that red stamp!” But his mum shook her head and said, “No, Tom. You don’t need it. We already have enough stamps.”
So Tom kept asking and eventually his mum said, “You can borrow a stamp from your friend. That’s much nicer than taking something you don’t need.”
So Tom went to his friend’s house and asked if he could borrow a stamp. His friend said yes and gave Tom a nice, red stamp.
Tom was so happy and learnt a lesson - it’s better to ask and share than to take something you don’t need.
<|endoftext|>
Mia was building lots of different shapes with blocks. She had built a big circle and a square and lots of different shapes! Daddy came in to join her and asked what she had built.
"I've made a circle and a square," explained Mia. "I'm going to make a cube next!"
Mia started to lay out the blocks in a cube shape. Daddy sat down and watched her build. After a while, the cube was finished!
"Look Daddy, I made a cube!" exclaimed Mia.
"That's great Mia," said Daddy.
"That cube looks really fit," he said.
Mia smiled and she was really proud of her cube. Then she started to make another cube. This one was even more fit!
<|endoftext|>
Once upon a time there was a prince who was very rude. He was always unkind to everyone he met.
One day he met a little girl who was only three years old. She was so sweet and kind. The prince thought it would be fun to pick on her.
The girl looked up at the prince and said, "Why are you being so mean to me?"
The prince snarled and said, "Because I can."
The little girl stood up tall and bravely said, "I will not let you be so rude! We must fight!"
The prince was surprised. He asked, "What do you mean fight?"
The little girl smiled and said, "I mean that we can fight with our words. We can both be kind and polite. We can have a nice conversation."
The prince thought about this for a moment and realized how silly he had been. He nodded and said, "Ok. Let's do that!"
Since then the prince and the little girl have become friends. They talk every day and never fight with words.
<|endoftext|>
Tiny Tom was walking in the park with his mom when he suddenly saw a huge well. He looked up at his mom with excitement and asked, "What is that well mommy?". His mom smiled and replied, "Well, it's a very deep hole in the ground with water at the bottom, sweetheart".
Tom couldn't believe his eyes. He wanted to see what was in the huge well. So he stepped closer to the edge and took a look inside. Suddenly, he lost his footing and was about to fall in the well. His mom quickly ran to him and grabbed him, just in time.
Tom started to cry and his mom hugged him tightly. She then said, "I know you are curious, Tom, but it can be dangerous to investigate things without knowing them. Let's take a quick break to calm down.
Tom sighed, and looked away, embarrassed. He realized he had done something wrong and said sorry to his mom. Together, they returned home and his mom reminded him that curiosity was a good thing but it's important to always be careful.
<|endoftext|>
One day, a fox was wandering through the forest. The fox moved quickly and gracefully, her playful spirit showing in her every step. All of a sudden, she saw a small rabbit ahead. The rabbit immediately seemed scared and ran away.
The fox was surprised, for she had no intention of scaring away the rabbit. She wanted to make friends!
The fox chased after the rabbit and called out, "Don't be scared! I just want to be your friend."
The rabbit stopped and looked back. It crept back slowly, not sure if it could trust the fox.
The fox declared firmly, "I won't ever hurt you. I promise!"
Th