The screenplay is based on Niè Yǐnniáng [聶隱娘], a wǔxiá short story by Péi Xíng [裴铏]. The story is set under the Táng against a semi-historical background, and is one of the very first nǚxiá (female knight-errant) tales, if not the first one. I haven't seen the film yet (it is released on 9 March here in Paris), but my understanding is that it departs from the short story.
Anyway, here is a translation of the short story that I found on-line:
Niè Yǐnniáng was the daughter of Niè Fēng, the General of Wèibó (an area in modern day Héběi Province) during the Zhēngyuán Period of Emperor Dézōng’s reign in the Táng Dynasty. She was only 10 when a Buddhist nun came to beg for alms. Fond of Yǐnniáng, the nun asked the general: “Will you give me your daughter and allow me to educate her?”
General Fēng was angered by this, rejecting and reprimanding her.
The nun, however, remained stalwart, threatening the mighty general: “Even if you put her in an iron locker, I will still take her away.” The little girl disappeared that very night.
Astounded and dismayed, the general ordered a search of the area for his missing daughter, but to no avail. Thoughts of their missing daughter haunted the general and his wife for years to come.
Five years later, the nun returned with Yǐnniáng. “Her training is finished, and it’s time for her to return home,” the nun explained. As the girls’ parents celebrated the return of their daughter, the nun vanished in an instant. The family wept with joy.
When asked about her years of training, Yǐnniáng simply replied: “It was just reciting scripture at first, nothing else.” With disbelief, her father asked again, Yǐnniáng replied: “I don’t know what to do. You wouldn’t believe me, even if I told you honestly.” General Fēng reassured her, encouraged her to speak.
Yǐnniáng began her tale: “When I was first taken, in the dark, I had no idea how far I had travelled with the nun. At dawn, I found myself in a large cave. There were no people outside, only a thick forest that housed many apes and monkeys. There were already two girls in the cave, both 10 years old as well. They were beautiful and smart, but I never saw them eat. They bounced around the steep mountain cliffs like apes in the trees and never fell. The nun then made me swallow a mysterious pill and handed me a two-foot long sword. It was so sharp that you could cut a hair in half by blowing it toward the blade. I learned mountain climbing with the two girls. Gradually, my body became lighter and lighter. After a year of sword practice, I was able to hunt apes. Later, I switched my target to beasts such as tigers and leopards. Every time I tried, I cut their heads off with ease. Three years later, I could stab eagles in the sky. By this time, my blade had worn down to only six inches, but I could still attack birds easily.
“In the fourth year, the two girls stayed back to guard the cave while I was taken to the city. I had no idea where I was, but the nun pointed to a man in the crowd, explaining his sins and crimes in great detail, then she said: ‘Cut his head off for me when his guard is down. He will be as easy a target as a bird.’ She then passed me a three-inch dagger. In broad daylight, on a bustling street, I decapitated him without raising any attention. I stuck his head into a bag and brought it back to the cave. Later, the nun used potions to turn the head into water.
“In the fifth year, the nun assigned me another assassination. She said: ‘That official is sinful. Many innocent people have died at his hands. Go to his room in the night and cut his head off.’ So, I went with my dagger and snuck into the house through an unclosed door. I hid on a beam as the official played with his child, and I didn’t do the deed until daybreak, bringing his head back to the nun. The nun was in a thundering range and asked why I was so late. I told her: ‘I saw the official playing with his child. It was so lovely that I couldn’t bring myself to kill him.’ But the nun snapped at me: ‘The next time that happens, you kill the child first. Kill his loved ones before you end his life.’ At that lesson, I could only bow.
“Then, one day, the nun said, ‘You can hide a dagger in the back of your head, let me show you. It won’t hurt. And, now you can draw it out whenever you need it.’ Amazing as it seems, the nun did as she said, continuing: ‘Your training is coming to an end. You can go back home.’ When we were parting, she also told me that she would see me again in 20 years.”
Yǐnniáng’s strange tale struck fear deep into her father’s heart.
Later, Yǐnniáng was discovered to be disappearing into the night, only to reappear in the morning. General Fēng was too scared to enquire as to her whereabouts. But with this fear, his love for her began to diminish.
One day, a mirror polisher was passing by Yǐnniáng, and she told her father: “That young man can be my husband.” Fēng didn’t dare to refuse and married Yǐnniáng to the young man. Yǐnniáng’s husband had only one skill—polishing mirrors, nothing else. So General Fēng provided generously for the couple but kept both of them at a distance.
Years later, Fēng passed away. By then, the Commander of Wèi had heard of Yǐnniáng’s skills, hiring her and her husband as his close officers. This went on until the Yuánhé Period (806-820) under Emperor Xiànzōng. One day, the commander found himself an enemy—the Governor of Chénxǔ, Liú Chāngyì.
The commander sent the couple to collect Liú’s head. This time, things did not go so smoothly. As they set out, Liú foresaw their coming, and gathered his officers: “Wait at the north of the city tomorrow morning; you will see a man and a woman riding a white donkey and a black donkey respectively. The man will try to shoot a magpie with a slingshot and miss. The woman will grab the slingshot and hit the magpie with a single shot. Bow and inform them that I sent you there to greet them.”
Everything went exactly as Liú said. The surprised couple said: “Governor Liú is an amazing prophet. How else would he know we were coming? We wish to meet him.” When Liú arrived, the couple bowed and apologised: “We deserve the punishment of death for such malicious intent!”
Liú replied: “No, you were only carrying out orders. I wish to hire you. Please stay here and trust in me.” Yǐnniáng realised that her old master could not compare to Liú and agreed: “My governor, we are convinced by your talents and are happy to serve you.” When Liú asked about compensation, the couple said, “Two hundred bronze coins per day will be more than sufficient.” Their demands were met. Later on, Liú found out that the couple’s donkeys were missing. He ordered a search, eventually finding a pair of paper donkeys in a bag, one white, the other black, causing the great governor to infer that—as well as having considerable martial powers—Yǐnniáng and her husband possessed powerful magic.
A month passed and Yǐnniáng told Liú: “Our former commander does not know we now serve you. He will send others. Cut some of your hair and wrap it in red silk. I will put it on his pillow to let him know our loyalties have changed.” Liú did as she said, returning early the next morning, saying: “The message is sent. The commander will order an assassin named Jīngjīnger to kill me and collect your head in the early hours of the morning, but don’t worry, I will find a way to defeat him.” Liú was relieved and showed no signs of fear, but he did light candles during the night and remained alert. At midnight, a red flag and a white flag magically appeared, floating and seemingly fighting with each other around his bed. Suddenly, a head and a body fell from thin air. Yǐnniáng appeared, triumphant: “Jīngjīnger is dead.” She dragged the corpse outside and turned it into water with the potion the old nun used, consuming even the corpses’ hair.
Yǐnniáng later issued Liú a warning: “There will be another assassin named Kōngkònger early tomorrow morning. His skills are mysterious and magical. No human has ever lived to speak of his power, even ghosts can’t track him down. He will sneak in without so much as a shadow. I am no match for him. This time, you will have to depend on luck. Please wear Yúnnán jade around your neck and cover yourself with blankets. I will turn into a small insect and hide in your intestines—the only place I won’t be discovered.” During the night, Liú did what Yǐnniáng suggested. With eyes closed, he lay on his bed. Suddenly, a loud noise rang from his neck. Yǐnniáng jumped from Liú’s mouth to congratulate him: “You are safe! Like an eagle, the assassin only strikes once and flees. He is deeply ashamed by the failure and will be hundreds of miles away in a few hours.” Later, Liú checked the jade and found a deep dagger mark. In gratitude and amazement, he awarded Yǐnniáng and her husband with handsome gifts.
In the eighth year of the Yuánhé Period (813), Liú was transferred from Chénxǔ to the capital. Yǐnniáng did not wish to go with him. She said: “I will travel to various mountains and lakes to visit the saints. All I ask is that you give my husband a small position.” Liú agreed and gradually lost contact with her.
When Liú passed away, Yǐnniáng arrived at the capital on her white donkey and grieved at her former master’s memorial.
During the Kāichéng Period (836-840) under Emperor Wénzōng, Liú’s son, Liú Zòng, was on his way to report for duty as the Governor of Língzhōu. On an old plank road in Sìchuān, he ran into Yǐnniáng, whose appearance hadn’t changed a bit; she still rode upon a white donkey. At the reunion, Yǐnniáng gravely told Zòng: “I see a great disaster in your future, you should not be here.” She gave him a pill and asked him to swallow it. “Quit your position next year and go back to your hometown of Luòyáng. It’s the only way to avoid this disaster. My pill will only keep you safe for one year,” she said. Though Zòng had his doubts, he thanked her and offered colourful silk as a gift. Yǐnniáng refused and disappeared. Sadly, Liú’s son did not heed her words, and—after one year—Zòng kept his position. He died mysteriously in Língzhōu. That was the last time anyone ever saw Yǐnniáng, the great female assassin.